SQLServer查詢使用者儲存過程

ywxj_001發表於2022-11-17

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部落格 ” ,連結:http://blog.itpub.net/22996654/viewspace-2923886/,如需轉載,請註明出處,否則將追究法律責任。

相關文章