--1、檢視所有儲存過程與函式
exec sp_stored_procedures
或者 select * from dbo.sysobjects where objectproperty(id, n'isprocedure') = 1 order by name
--2、檢視儲存過程的內容
select text from syscomments where id=object_id('儲存過程名稱')
-- 或者用
sp_helptext 儲存過程名稱
--3、檢視儲存過程的引數情況
select '引數名稱' = name,
'型別' = type_name(xusertype),
'長度' = length,
'引數順序' = colid,
'排序方式' = collation
from syscolumns
where id=object_id('儲存過程名稱')
--或者
--檢視儲存過程引數資訊:
--如果返回值》1,則有引數。否則無
create proc sp_proc_params
@procedure_name sysname , --儲存過程或者使用者定義函式名
@group_number int=1 , --儲存過程的組號,必須在0到32767之間,0表示顯示該儲存過程組的所有引數
@operator nchar(2)=n'=' --查詢物件的運算子
as set nocount on
declare @sql nvarchar(4000)
set @sql=n'select
porcedurename=case
when o.xtype in(''p'',''x'')
then quotename(o.name)+n'';''+cast(c.number as varchar)
when user_name(o.uid)=''system_function_schema''
and o.xtype=''fn''
then o.name
when user_name(o.uid)=''system_function_schema''
then ''::''+o.name
when o.xtype=''fn''
then quotename(user_name(o.uid))+n''.''+quotename(o.name)
else quotename(o.name) end,
owner=user_name(o.uid),
groupnumber=c.number,
paramid=c.colid,
paramname=case
when o.xtype=''fn'' and c.colid=0 then ''''
else c.name end,
type=quotename(t.name)+case
when t.name in (''decimal'',''numeric'')
then n''(''+cast(c.prec as varchar)+n'',''+cast(c.scale as varchar)+n'')''
when t.name=n''float''
or t.name like ''%char''
or t.name like ''%binary''
then n''(''+cast(c.prec as varchar)+n'')''
else '''' end,
orientation=case
when o.xtype=''fn'' and c.colid=0 then ''''
else n''input''
+case when c.isoutparam=1 then ''/output'' else '''' end
end
from sysobjects o,syscolumns c,systypes t
where o.id=c.id
and c.xusertype=t.xusertype
and o.name'
+case when @operator in ('=','>','>=','!>','<','<=','!<','<>','!=')
then @operator+quotename(@procedure_name,'''')
when @operator='in'
then @operator+n' in('+quotename(@procedure_name,'''')+')'
when @operator in ('like','%')
then ' like '+quotename(@procedure_name,'''')
else '='+quotename(@procedure_name,'''')
end+n'
and(('+case when @group_number between 1 and 32767
then n'c.number='+cast(@group_number as varchar)
when @group_number=0 then n'1=1'
else n'c.number=1'
end+n' and o.xtype in(''p'',''x''))
or (c.number=0 and o.xtype=''fn'')
or (c.number=1 and o.xtype in(''if'',''tf'')))'
exec sp_executesql @sql
--4、檢視所有儲存過程內容
select b.name ,a.text from syscomments a,sysobjects b where object_id(b.name)=a.id and b.xtype in('p','tr')
--5、檢視包含字串內容的儲存過程
select b.name ,a.text from syscomments a,sysobjects b
where
charindex('字串內容',a.text)>0 and
object_id(b.name)=a.id and b.xtype in('p','tr')
SQL儲存過程相關資訊檢視
1 檢視所有儲存過程與函式 exec sp stored procedures 或者select from dbo.sysobjects where objectproperty id,n isprocedure 1 order by name 2 檢視儲存過程的內容 select text fro...
SQL儲存過程相關資訊檢視轉
1 檢視所有儲存過程與函式 exec sp stored procedures 或者 select from dbo.sysobjects where objectproperty id,n isprocedure 1 order by name 2 檢視儲存過程的內容 select text fr...
SqlServer中Sql檢視儲存過程
一 利用sql語句查詢資料庫中的所有表 1.利用sysobjects系統表 select from sysobjects where xtype u 2,利用sys.tables目錄檢視 sys.tables目錄檢視,為每個表物件返回一行.select from sys.tables 注意 sys....