January 22, 2008 at 9:32 pm
Adding a new NOT NULL field to an existing table
January 22, 2008 at 10:02 pm
If any data existing in the table copy the same into a temparory table. Delete the records in the table and alter the table. Insert the records into table from temporary table.
January 22, 2008 at 10:07 pm
Just add the column as a nullable column. Then populate it. When you're done, alter the column to be not null.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 22, 2008 at 10:09 pm
one other approach is to give it a default value, then drop the default constraint.
January 23, 2008 at 12:33 am
if you use
alter table xyz add mycol int not null default 0
keep in mind to rebuild your indexes afterward because your clusterratio may be horrible !
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply