sp_helptext

Transact-SQL Reference

Transact-SQL Reference

sp_helptext

Prints the text of a rule, a default, or an unencrypted stored procedure, user-defined function, trigger, or view.

Syntax

sp_helptext [ @objname = ] 'name'

Arguments

[@objname =] 'name'

Is the name of the object for which to display definition information. The object must be in the current database. name is nvarchar(776), with no default.

Return Code Values

0 (success) or 1 (failure)

Result Sets
Column name Data type Description
Text nvarchar(255) Object definition text
Remarks

sp_helptext prints out the text used to create an object in multiple rows, each with 255 characters of the Transact-SQL definition. The definition resides in the text in the syscomments table of the current database only.

Permissions

Execute permissions default to the public role.

Examples

This example displays the text of the employee_insupd trigger, which is in the pubs database.

USE pubs
EXEC sp_helptext 'employee_insupd'

See Also

CREATE PROCEDURE

CREATE TRIGGER

CREATE VIEW

sp_help

System Stored Procedures