declare cur cursor for
select a.text from syscomments a,sysobjects b
where object_id(b.name)=a.id and b.xtype in('P','TR')
open cur
fetch cur into @proc_content
while @@FETCH_STATUS=0
begin
--这句保证存储过程能修改
set @proc_content = replace(@proc_content,'create proc','alter proc')
--这句是关键,你要做的替换,要保证替换不会替换掉无关内容
set @proc_content = replace(@proc_content,'day(getdate())','month(getdate())')
exec (@proc_content)
fetch cur into @proc_content
end
close cur
deallocate cur
1 个回复
悟 - 取是能力,舍是境界 2015-10-13 回答
赞同来自: yuluscut