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;