I have a table and I want to drop or set the default value of one of columns. I use below scripts :
ALTER TABLE AccAccountGroup ALTER COLUMN Name DROP DEFAULT
ALTER TABLE AccAccountGroup ALTER COLUMN Name SET DEFAULT 'default value'
when I run the scripts, below errors appears :
Incorrect syntax near the keyword 'DEFAULT'. => for drop script
Incorrect syntax near the keyword 'SET'. => for add script
these scripts are from msdn.
What is the problem? I use SQL Server 2008 R2.
I believe that your reference is for SQL Server Compact Edition. Use this one instead.
You need to use the CONSTRAINT syntax and you need to use the default’s name. Even though you didn’t assign a name (and I suggest that you do in the future as it’s a good practice), SQL Server will assign one, which you can find using
EXEC sp_help AccAccountGroup.Try these syntaxes: