美文网首页sql server
SQL 查询所有存储过程,表,视图 包含某个字符串或者字段

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

作者: 长夏丶低吟 | 来源:发表于2019-07-19 11:23 被阅读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 类型

相关文章

网友评论

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

    本文链接:https://www.haomeiwen.com/subject/mqsjlctx.html