SQLTeam.com | Weblogs | Forums

How to update only newly added column values without updating other values


I have added one new column in my table and want to add entries in that column only, how could i do single value and multiple values in that table by using inseart query


INSERT statement is used for inserting new rows into a table. To change the values in one or more columns in existing rows, you would use the UPDATE statement.

UPDATE YourTable SET NewColumn = 0;

That will set the value of NewColumn to 0 in all rows in the table.

See MSDN documentation here.


Thanks James


you can not directly insert values in a single column without affecting other columns using insert. you can use Update instead of Insert.


Probably too late now, but if you just wanted an "initial value" then when you add a new column you can also create a DEFAULT, and all existing rows will be set to that value. This has the benefit that you can create the new column as not allowing NULLs, if you want to.

If the initial default is not appropriate longer term, after the column has been created, then you can DROP the DEFAULT as soon as the column has been added.