Several system stored procedures use system tables to provide information about stored procedures. You can use these stored procedures:
- View the statements used to create a stored procedure. This is useful for users who do not have a Transact-SQL script file used to create a stored procedure.
- Obtain information about a stored procedure, such as the owner, Creation Time, and parameters of the stored procedure ).
- Lists the objects used by the specified stored procedure and the procedure for using the specified stored procedure. This information can be used to identify the processes affected by changes or deletions to an object in the database.
View the definition of the stored procedure sp_helptext
Displays the text of rules, default values, unencrypted stored procedures, user-defined functions, triggers, or views.
Syntax
Sp_helptext[@ Objname =]'Name'
Parameters
[@ Objname =]'Name'
Object Name. The definition information of the object is displayed. The object must be in the current database.NameThe data type of isNvarchar (776), No default value.
Return Code Value
0 (successful) or 1 (failed)
Result set
Column name |
Data Type |
Description |
Text |
Nvarchar (255) |
Object definition text |
Note
Sp_helptextThe text used to create an object is displayed in multiple rows. Each row contains 255 characters defined by Transact-SQL. These definitions only reside in the current databaseSyscommentsTable text.
Permission
Execution permission is granted by defaultPublicRole.
Example
The following example showsEmployee_insupdTrigger text, which is stored in the databasePubs.
Use pubs