Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add default constraint in code
Message
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Add default constraint in code
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01547085
Message ID:
01547085
Views:
56
Hi,

I have a table where I added a default in SSMS. So the default has a constraint name (e.g. 'DF_table_name_col_name')

Now I wanted to drop this default constraint and create a new one; in code. Dropping it seems to be easy. But when I try to create the new default constraint in code I get error. Here is syntax I use:
alter table table_name alter column col_name char(20) not null add constraint [DF_table_name_col_name] default ('')
What is wrong with my syntax above? TIA.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Next
Reply
Map
View

Click here to load this message in the networking platform