3

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'.

Nisar
  • 5,708
  • 17
  • 68
  • 83

4 Answers4

3

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Smaug
  • 2,625
  • 5
  • 28
  • 44
3

Use ADD CONSTRAINT

ALTER TABLE MBR_MST2 ADD CONSTRAINT DF_NewSTS DEFAULT 1 FOR MBR_STS;
Giannis Paraskevopoulos
  • 18,261
  • 1
  • 49
  • 69
1

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
Community
  • 1
  • 1
BLaZuRE
  • 2,356
  • 2
  • 26
  • 43
0
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.

Vojtech Ruzicka
  • 16,384
  • 15
  • 63
  • 66
Raphael
  • 31
  • 3