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,280
  • 15
  • 61
  • 82

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
  • 704,970
  • 168
  • 1,303
  • 1,425
Smaug
  • 2,565
  • 5
  • 27
  • 42
3

Use ADD CONSTRAINT

ALTER TABLE MBR_MST2 ADD CONSTRAINT DF_NewSTS DEFAULT 1 FOR MBR_STS;
Giannis Paraskevopoulos
  • 17,836
  • 1
  • 48
  • 66
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,325
  • 2
  • 25
  • 41
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
  • 15,149
  • 15
  • 63
  • 63
Raphael
  • 31
  • 3