如何修改列的默认值T-SQL
没有办法直接通过脚本修改列的默认值。只能先删除原来默认值的约束,再重新添加默认值的约束
SELECT d.definition d.name,*FROM sys.default_constraints AS dINNER JOIN sys.columns AS cON d.parent_column_id = c.column_idWHERE d.parent_object_id = OBJECT_ID(N'table name', N'U')AND c.name = 'column name';----alter table [table name]drop constraint [上面d.name]goalter table [table name]add constraint 约束的名字 default 1 for column Namegoexec sp_helpconstraint [table name]