Reputation: 6038
I HAVE FOLLOWING QUERY... THROUGH WHICH I WANT TO ALTER DEFAULT VALUE
ALTER TABLE MBR_MST2 ALTER COLUMN MBR_STS SET DEFAULT 1
don't know why it is showing an error Incorrect syntax near the keyword 'SET'.
Upvotes: 3
Views: 5751
Reputation: 31
ALTER TABLE MBR_MST2 ALTER COLUMN MBR_STS SET DEFAULT 1
Rewrite as
ALTER TABLE MBR_MST2
add constraint DF_MBR_MST2_MBR_STS
Default 'DEFAULT 1' For MBR_STS
Open your table and refresh it's constraints folder and this constraint should be there.
Upvotes: 0
Reputation: 2673
The query as follows will sort it out. Refer the below handy code sample has been written by Pinal Dave
ALTER TABLE MBR_MST2
ADD CONSTRAINT MBR_MST2_CONST DEFAULT 1 FOR MBR_STS
Handy Script Link for Default Constraint
Upvotes: 3
Reputation: 2406
Read the documentation for your statement. Your error is correct, the syntax is incorrect.
Look at this question for the correct syntax.
ALTER TABLE MBR_MST2 ADD CONSTRAINT Your_Constraint_Name DEFAULT 1 FOR MBR_STS
Upvotes: 1
Reputation: 18431
Use ADD CONSTRAINT
ALTER TABLE MBR_MST2 ADD CONSTRAINT DF_NewSTS DEFAULT 1 FOR MBR_STS;
Upvotes: 3