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.
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.
Use ADD CONSTRAINT
.
For example:
ALTER TABLE enquiry ADD CONSTRAINT some_name DEFAULT 0 FOR RejectReson;
ALTER TABLE enquiry ADD DEFAULT 0 FOR RejectReson
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.