sql server

SQL 查询所有存储过程,表,视图 包含某个字符串或者字段

2019-07-19  本文已影响0人  长夏丶低吟

存储过程包含

select name

from sysobjects o, syscomments s

where o.id = s.id

and text like '%请输入你要查询的内容%'

and o.xtype = 'P'

表包含

SELECT t.name AS table_name,

c.name AS column_name

FROM  sys.tables AS t

INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID

WHERE c.name LIKE'%请输入你要查询的内容%'

视图包含

select name,case when o.xtype = 'V' then '视图' when o.xtype = 'P' then '存储过程' when o.xtype = 'T' then '表' else '其他' end as '类型'

from sysobjects o, syscomments s

where o.id = s.id

and text like '%请输入你要查询的内容%'

and o.xtype IN( 'V','P','T') ORDER BY 类型

上一篇 下一篇

猜你喜欢

热点阅读