--1, to view all stored procedures and functions
exec sp_stored_procedures
or
SELECT * WHERE dbo.sysobjects from the OBJECTPROPERTY (ID, N'IsProcedure ') =. 1 Order by name
--2, view the contents of a stored procedure
select text from syscomments where id = object_id ( 'stored procedure name')
- or with the
name of the stored procedure sp_helptext
--3, parameters are stored procedure to see
select 'parameter name' = name,
'type' = TYPE_NAME (xusertype),
'length' = length,
'order parameter' = the colid,
'sort' = collation
from the syscolumns
WHERE ID = object_id ( 'stored procedure name')
--or
- View stored procedure parameter information:
- If the return value> 1, there are parameters. Otherwise, without
the CREATE the PROC sp_PROC_Params
@procedure_name Sysname, - stored procedures or user-defined function name
@group_number int = 1, - the group number stored procedure, must be between 0 to 32767, 0 represents a stored procedure that displays all parameters set
@operator nchar (2) = N ' =' - Find the object operator
the AS
the SET the NOCOUNT the ON
the DECLARE @SQL nvarchar (4000)
the SET @ = N'select the SQL
PorcedureName the CASE =
the WHEN o.xtype the iN ( '' P '' , '' X-'')
THEN the QUOTENAME (o.name) + N ''; '' + the CAST (c.number AS VARCHAR)
the WHEN USER_NAME (o.uid) = '' system_function_schema ''
the AND o.xtype = '' FN ''
THEN o.name
the WHEN USER_NAME (O.
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 ''<Returns>''
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 ''<Returns>''
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 view all contents stored procedures
select b.name, a.text from syscomments a, sysobjects b where object_id (b.name) = a.id and b.xtype in ( 'P', 'TR')
--5, view the contents of the stored procedure contains the string
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')
--1, to view all stored procedures and functions
exec sp_stored_procedures
or
SELECT * WHERE dbo.sysobjects from the OBJECTPROPERTY (ID, N'IsProcedure ') =. 1 Order by name
--2, view the contents of a stored procedure
select text from syscomments where id = object_id ( 'stored procedure name')
- or with the
name of the stored procedure sp_helptext
--3, parameters are stored procedure to see
select 'parameter name' = name,
'type' = TYPE_NAME (xusertype),
'length' = length,
'order parameter' = the colid,
'sort' = collation
from the syscolumns
WHERE ID = object_id ( 'stored procedure name')
--or
- View stored procedure parameter information:
- If the return value> 1, there are parameters. Otherwise, without
the CREATE the PROC sp_PROC_Params
@procedure_name Sysname, - stored procedures or user-defined function name
@group_number int = 1, - the group number stored procedure, must be between 0 to 32767, 0 represents a stored procedure that displays all parameters set
@operator nchar (2) = N ' =' - Find the object operator
the AS
the SET the NOCOUNT the ON
the DECLARE @SQL nvarchar (4000)
the SET @ = N'select the SQL
PorcedureName the CASE =
the WHEN o.xtype the iN ( '' P '' , '' X-'')
THEN the QUOTENAME (o.name) + N ''; '' + the CAST (c.number AS VARCHAR)
the WHEN USER_NAME (o.uid) = '' system_function_schema ''
the AND o.xtype = '' FN ''
THEN o.name
the WHEN USER_NAME (O.
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 ''<Returns>''
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 ''<Returns>''
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 view all contents stored procedures
select b.name, a.text from syscomments a, sysobjects b where object_id (b.name) = a.id and b.xtype in ( 'P', 'TR')
--5, view the contents of the stored procedure contains the string
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')