December 5, 2006 at 6:39 pm
I have a column that I need to change the size in multiple production servers.
I have also a default on this column and it is not null.
I use a SP (custom written) to drop the default and then change the column size from int to big int, but then I cannot recreate the default for this Not Null column with the alter table... alter column statement.
Is there a way to do that within the Alter table - alter column statement? Some work around?
Thanks a lot, mj
December 5, 2006 at 7:33 pm
you could simply add the constraint to the table: you might need to update the table to the new value prior to adding the constraint
update mytable set myNewColumn=50 where MyNewColumn is null;
ALTER TABLE MyTable
ADD CONSTRAINT DF_MyCol_Default
DEFAULT 50 FOR MyNewColumn ;
Lowell
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply