SQL Server 获取某时间点后修改的函数Function 并以文本格式显示

修改查询分析器如下选项

右键=》查询选项 =》结果=》文本=》 取消 在结果集中包括列标题 的勾选

右键=》将结果保存到=》 选择 以文本格式显示结果

执行如下SQL

declare @funcname nvarchar(100)=N'';
declare curFunc cursor for
select 
 [name]
 --,create_date
 --,modify_date 
FROM 
 sys.all_objects 
where 
 type_desc LIKE '%FUNCTION%'
 and substring([name],1,3) not in ('dm_','fn_')
 and modify_date >='2013-07-11 00:00:00'
order by 
 modify_date desc;

open curFunc;
fetch next from curFunc into @funcname;
while @@FETCH_STATUS = 0 
begin
 print(N'IF EXISTS(SELECT 1 FROM SYS.OBJECTS WHERE [NAME]=N''' + @funcname +''' AND [TYPE]=''FN'')')
 PRINT(N'DROP FUNCTION ' + @funcname);
 print N'GO';
 exec ('sp_helptext ' + @funcname);
 print N'GO';
 fetch next from curFunc into @funcname;
end
close curFunc;
deallocate curFunc;

  

 

 

posted on 2013-07-12 17:10  freeliver54  阅读(452)  评论(2编辑  收藏  举报

导航