ITPub博客

首页 > 数据库 > SQL Server > SQLServer查询用户存储过程

SQLServer查询用户存储过程

原创 SQL Server 作者:ywxj_001 时间:2022-11-17 16:41:40 0 删除 编辑

SQLServer查询用户存储过程:

with syso as (

SELECT sp.object_id 

FROM sys.all_objects AS sp

LEFT OUTER JOIN sys.database_principals AS ssp ON ssp.principal_id = ISNULL(sp.principal_id, (OBJECTPROPERTY(sp.object_id, 'OwnerId')))

LEFT OUTER JOIN sys.sql_modules AS smsp ON smsp.object_id = sp.object_id

LEFT OUTER JOIN sys.system_sql_modules AS ssmsp ON ssmsp.object_id = sp.object_id

WHERE

(sp.type IN('P','RF','PC')and(CAST(

 case 

    when sp.is_ms_shipped = 1 then 1

    when (

        select 

            major_id 

        from 

            sys.extended_properties 

        where 

            major_id = sp.object_id and 

            minor_id = 0 and 

            class = 1 and 

            name = N'microsoft_database_tools_support') 

        is not null then 1

    else 0

end  AS bit)=1))

)select a.name,a.type,b.definition 

from sys.procedures a,sys.sql_modules b 

where a.object_id = b.object_id 

and a.object_id  not in (select object_id  from syso)

order by a.name asc;


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22996654/viewspace-2923886/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
在零售、金融、互联网行业从事数据库相关工作10余年,有丰富的数据库管理和架构的相关经验。 涉及SQLServer、Oracle、MySQL、PostgreSQL等多种数据库。 目前在一家互联网公司担任DBA经理。 负责整个集团数据库的架构设计和管理工作。

注册时间:2010-01-19

  • 博文量
    247
  • 访问量
    437822