SQL - Add constraint for an existing column
-----alter an existing column to have default value
update tbl_name
set appended =
getdate()
alter table tbl_name
alter column appended
DATETIME NOT NULL ;
ALTER TABLE tbl_name
ADD CONSTRAINT DF_Constraint
DEFAULT GetDate() FOR appended;
-----get two digit month
CONVERT(char(2),
GetDate(), 101)
No comments:
Post a Comment