Was this page helpful?
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

sp_helptext (Transact-SQL)


Applies To: SQL Server 2014, SQL Server 2016 Preview

Displays the definition of a user-defined rule, default, unencrypted Transact-SQL stored procedure, user-defined Transact-SQL function, trigger, computed column, CHECK constraint, view, or system object such as a system stored procedure.

Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.

Topic link icon Transact-SQL Syntax Conventions

sp_helptext [ @objname = ] 'name' [ , [ @columnname = ] computed_column_name ]

[ @objname = ] 'name'

Is the qualified or nonqualified name of a user-defined, schema-scoped object. Quotation marks are required only if a qualified object is specified. If a fully qualified name, including a database name, is provided, the database name must be the name of the current database. 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 name. column_name is sysname, with no default.

0 (success) or 1 (failure)

Column name

Data type




Object definition

sp_helptext displays the definition that is used to create an object in multiple rows. Each row contains 255 characters of the Transact-SQL definition. The definition resides in the definition column in the sys.sql_modules catalog view.

Requires membership in the public role. System object definitions are publicly visible. The definition of user objects is visible to the object owner or grantees that have any one of the following permissions: ALTER, CONTROL, TAKE OWNERSHIP, or VIEW DEFINITION.

The following example displays the definition of the trigger dEmployee in the AdventureWorks2012database.

USE AdventureWorks2012;
EXEC sp_helptext 'HumanResources.dEmployee';

The following example displays the definition of the computed column TotalDue on the SalesOrderHeader table in the AdventureWorks2012 database.

USE AdventureWorks2012;
sp_helptext @objname = N'AdventureWorks2012.Sales.SalesOrderHeader', @columnname = TotalDue ;

Here is the result set.




Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft