This isn't working in SQL Server 2008:
ALTER TABLE Employee ALTER COLUMN CityBorn SET DEFAULT 'SANDNES'
The error is:
Incorrect syntax near the keyword 'SET'.
What am I doing wrong?
This isn't working in SQL Server 2008:
ALTER TABLE Employee ALTER COLUMN CityBorn SET DEFAULT 'SANDNES'
The error is:
Incorrect syntax near the keyword 'SET'.
What am I doing wrong?
Hoodaticus's solution was perfect, thank you, but I also needed it to be re-runnable and found this way to check if it had been done...
The correct way to do this is as follows:
Run the command:
Copy the name of the
CONSTRAINT
.Drop the
DEFAULT CONSTRAINT
:Run the command below:
Like Yuck's answer with a check to allow the script to be ran more than once without error. (less code/custom strings than using information_schema.columns)
Just Found 3 simple steps to alter already existing column that was null before
First drop constraints
https://stackoverflow.com/a/49393045/2547164
Second create default value
Try following command;