Export (0) Print
Expand All
Expand Minimize
3 out of 7 rated this helpful - Rate this topic

sp_helptext

SQL Server 2000

  Topic last updated -- July 2003

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

Syntax

sp_helptext [ @objname = ] name
    [ , [ @columnname = ] computed_column_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.

[@columnname = ] computed_column_name

Is the name of the computed column for which to display definition information. The table that contains the column must be specified as objname and must be in the current database. computed_column_name is sysname, 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
A. Display the definition of a trigger.

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

USE pubs
EXEC sp_helptext employee_insupd
B. Display the definition of a computed column.

This example creates the computed column discountamount on the titles table in the pubs database and displays the definition of that computed column.

USE pubs
ALTER TABLE titles ADD discountamount AS price * .15
GO
sp_helptext @objname = titles, @columnname = discountamount
GO

Here is the result set:

Text
([price] * 0.15)

See Also

CREATE PROCEDURE

CREATE TRIGGER

CREATE VIEW

sp_help

System Stored Procedures

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.