create proc [dbo].[get_user_object]( @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
调用方法: [dbo].[uspGetDepends] '订单'
浙公网安备 33010602011771号