码迷,mamicode.com
首页 > 其他好文 > 详细

查询一段时间内修改过的存储过程

时间:2017-07-24 14:33:52      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:cti   nio   print   distinct   isnull   时间   objects   desc   exec   

declare @Platform nvarchar(100) = ‘库名‘
declare @Platform_BusinessData nvarchar(100) = ‘库名‘ 
declare @LastModifyDate nvarchar(100) = ‘2017-02-16 00:00:00‘  --修改时间

declare @sql nvarchar(max) = ‘
if OBJECT_ID(‘‘tempdb..#t‘‘) is not null drop table #t

select *
    into #t
    from (
    select ‘‘‘ + @Platform + ‘..‘‘ + o.name + isnull(‘‘.‘‘ + tb.name, ‘‘‘‘) name, o.create_date, o.modify_date,o.type_desc
        FROM ‘ + @Platform + ‘.sys.all_objects o
        left join ‘ + @Platform + ‘.sys.triggers t on t.object_id = o.object_id
        left join ‘ + @Platform + ‘.sys.tables tb on tb.object_id = t.parent_id
        union all
    select ‘‘‘ + @Platform_BusinessData + ‘..‘‘ + o.name + isnull(‘‘.‘‘ + tb.name, ‘‘‘‘), o.create_date, o.modify_date,o.type_desc
        FROM ‘ + @Platform_BusinessData + ‘.sys.all_objects o
        left join ‘ + @Platform_BusinessData + ‘.sys.triggers t on t.object_id = o.object_id
        left join ‘ + @Platform_BusinessData + ‘.sys.tables tb on tb.object_id = t.parent_id
    ) t
    where modify_date >=‘‘‘ + @LastModifyDate + ‘‘‘

--select distinct type_desc from #t

select * from #t
    where type_desc = ‘‘USER_TABLE‘‘
        
select * from #t
    where type_desc = ‘‘SQL_STORED_PROCEDURE‘‘
    
select * from #t
    where type_desc = ‘‘SQL_SCALAR_FUNCTION‘‘ or type_desc = ‘‘SQL_TABLE_VALUED_FUNCTION‘‘
    
select * from #t
    where type_desc = ‘‘VIEW‘‘
    
select * from #t
    where type_desc = ‘‘SQL_TRIGGER‘‘
‘    

print @Sql
exec sp_executesql @sql



-- select * from UBIPlatform..HY_SOLUTION where SolutionName like ‘Case%‘ or SolutionName like ‘%Review‘

查询一段时间内修改过的存储过程

标签:cti   nio   print   distinct   isnull   时间   objects   desc   exec   

原文地址:http://www.cnblogs.com/wancong/p/7228324.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!