勤学如春起之苗不见其增日有所长,辍学如磨刀之石不见其损日有所亏

 

ALTER proc [op].[uspGetDepends](
@StrName varchar(100),
@Type varchar(10) = 'all'
)
as
begin
set nocount on
--查询非用户表,即函数、存储过程、视图、约束等等。
select schema_name(schema_id) as [schema],*
from sys.objects
where object_id in(
select id from syscomments
where [text] like '%'+@StrName+'%'
and patindex('%201[0-9]%',[name]) = 0 --排除名字中包含年份的备份数据库对象
) and (@type = 'all' or [type] = @type)

union all
--查询用户自定表。
select schema_name(schema_id) as [schema],*
from sys.objects
where [name] like '%'+@StrName+'%'
and patindex('%201[0-9]%',[name]) = 0 --排除名字中包含年份的备份数据库对象
and [type] ='U' and ( @type='all' or @type = 'U')

order by [name]
set nocount off
end

posted on 2017-10-25 13:21  TheClound  阅读(388)  评论(0编辑  收藏  举报