SQL Server根据表名查询存储过程或试图

select a.name 来源名称,b.text 代码内容,
    case
        when a.xtype='V' then '视图'
        when a.xtype='P' then '存储过程'
        when a.xtype='FN' then '标量函数'
        when a.xtype='TF' then '表函数'
        when a.xtype='TR' then '触发器'
        else a.xtype
    end 类型
from sysobjects a inner join syscomments b on a.ID=b.ID
where b.text like '%需要查询的表%'
order by 类型

 

posted @ 2020-06-19 14:54  Hero-韦先生  阅读(518)  评论(0编辑  收藏  举报