0
alter table enquiry alter  column RejectReson int default 0

I want alter the column data type with default value zero,but it is not happening.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786

3 Answers3

1

Use ADD CONSTRAINT.

For example:

ALTER TABLE enquiry ADD CONSTRAINT some_name DEFAULT 0 FOR RejectReson;
GileBrt
  • 1,830
  • 3
  • 20
  • 28
0

ALTER TABLE enquiry ADD DEFAULT 0 FOR RejectReson

0

If you want to affect existing rows, then use with values:

alter table enquiry
    add constraint dft_enquiry_rejectreason default 0 with values;

This is explained in the documentation:

. . . WITH VALUES can be used to store the default value in the new column for each existing row in the table.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786