April 30, 2010 at 7:30 am
Thanks for your help. (mssqlserver 2005) I have a table called tier1 and a column named class nvarchar(150) it needs to have a default value set on that column. I know how to do it using managment studio, but I need to do it using code. How would I do this? Thanks!
April 30, 2010 at 7:36 am
Something like this.
ALTER TABLE tblA
ADD Class NVARCHAR(150) DEFAULT 'Some value'
April 30, 2010 at 7:38 am
George Murphy (4/30/2010)
Thanks for your help. (mssqlserver 2005) I have a table called tier1 and a column named class nvarchar(150) it needs to have a default value set on that column. I know how to do it using managment studio, but I need to do it using code. How would I do this? Thanks!
George just before saving a change like adding this default in the Design GUI, you could click the "Generate Change Script " button(the first button...scroll bar and save kind of icon) and see the code that the system would use;
it's just adding a default constraint, which would be like this:
ALTER TABLE tier1 ADD CONSTRAINT [DF_MyDefaultForClass] DEFAULT 'TheDefaultClass' FOR class
Lowell
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply