SQL Server 删除默认值

alter table st_FuelConvertPatternSetting alter column tank_max_size decimal(5,2) not null

declare @constraintname nvarchar(500);
declare @sql nvarchar(2000);

select @constraintname = OBJECT_NAME(cdefault) from syscolumns where id = object_id(N'st_FuelConvertPatternSetting')
and name='tank_max_size'
select @sql = N'alter table st_FuelConvertPatternSetting drop constraint ' +@constraintname
exec sp_executesql @sql
alter table st_FuelConvertPatternSetting add constraint DF_tank_max_size default(500.00) for tank_max_size

select @constraintname = OBJECT_NAME(cdefault) from syscolumns where id = object_id(N'st_FuelConvertPatternSetting')
and name='correction_factor'
select @sql = N'alter table st_FuelConvertPatternSetting drop constraint ' +@constraintname
exec sp_executesql @sql
alter table st_FuelConvertPatternSetting add constraint DF_correction_factor default(1.00) for correction_factor

转载于:https://www.cnblogs.com/dehuachenyunfei/p/10442092.html

你可能感兴趣的:(SQL Server 删除默认值)