Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Praveen Kandasamy
Starting Member
4 Posts |
Posted - 2015-04-25 : 05:25:50
|
How to set a default value to columns in table ..without dropping it.??Thanx in Advance |
|
bitsmed
Aged Yak Warrior
545 Posts |
Posted - 2015-04-25 : 05:32:33
|
alter table yourtablename alter column yourcolumnname set default 'yourdefaultvalue' |
|
|
Praveen Kandasamy
Starting Member
4 Posts |
Posted - 2015-04-25 : 05:39:28
|
Thanks bitsmed ...This is my alter statement alter table ROLEMASTERalter column ISSYSTEMGENERATED set default 'MSC003'when i run this query. its shows errorMsg 156, Level 15, State 1, Line 2Incorrect syntax near the keyword 'set'. |
|
|
bitsmed
Aged Yak Warrior
545 Posts |
Posted - 2015-04-25 : 05:49:58
|
Sorry, my mistake. The syntax is:alter table yourtablename add constraint yourconstraintname default yourdefaultvalue for yourcolumnnameSo in your case:alter table ROLEMASTER add constraint def_rolemaster_sysgen default 'MSC003' for ISSYSTEMGENERATED |
|
|
|
|
|