想把数据库所有表中数据类型为 numeric 的列设一个默认值0,要如何做?
如题
[解决办法]
select 'alter table '+OBJECT_NAME(object_id)+ ' ADD CONSTRAINT col_'+ name +'DEFAULT 0 FOR '+name+';'from sys.columns where system_type_id = 108
[解决办法]
执行下面语句后,把结果拷贝到分析器,再执行就可以.select 'alter table '+OBJECT_NAME(object_id)+ ' ADD CONSTRAINT col_'+ name +'DEFAULT 0 FOR '+name+';'from sys.columns where system_type_id = 108
[解决办法]
select 'alter table '+object_Name(a.id) + ' add constraint DF_'+a.name+' default 0 for '+a.name
from sysColumns a
inner join systypes b on a.xusertype=b.xusertype
where b.name='numeric'