由于以前设计考虑不全,现在只要用sql语句改写列的类型和大小。查了资料,调试通过(sql server 2005)
-- 声明一个变量查看一下的约束
declare @name varchar(50)
select @name =b.name from sysobjects b join syscolumns a on b.id = a.cdefault where a.id = object_id('table') and a.name ='column'
--打印出来查看验证
print(@name)
--删除以前的约束,改变列类型,添加新的约束
if len(@name)>0
begin
exec('alter table table drop constraint ' + @name)
exec('alter table table alter column column nvarchar(600)')
exec('alter table add default(''0'') for column')
--or alter table ff add constraint DF_ff_aa_112312 default ('2') for aa
end
查看表的触发器
select c.name as 触发器,a.name 相关的表,(select text from syscomments where id = c.id)
from sysobjects c ,sysobjects a
where c.type= 'tr' and c.xtype ='tr'
and c.parent_obj = a.id