var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Add column/update existing rows
I need to add a column in SQL Server 2005 and then update the existing rows (600 million) with a default value. The column is char(1).
What would be the best way to do this without causing alot of blocking during the update?
I assume the database is being updated live?
If you can bring it down for updating for a little while, you could this method
1) Create a temp table:
SELECT o.*, new_field_value as new_field_name
FROM old_table o
RENAME old_table to tmp_old_table
RENAME tmp_new_table to old_table
Thats a very good idea but I won't be able to take the db offline during the update.
Do you have an id column in there somewhere? Then you could update all the rows in a range until you've done them all. You'd need to do some timings to see how long the updates would take. And check to see if there is enough log space.
I don't have an id column but i do have an int column. It isn't unique but i can update in groups based on that. That might be the best plan. Thanks for your help.