sp_helptext (Transact-SQL)sp_helptext (Transact-SQL)

適用於: 是SQL Server 是Azure SQL Database 否Azure SQL 資料倉儲 否平行處理資料倉儲 APPLIES TO: yesSQL Server yesAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

顯示使用者自訂規則定義、預設值、未加密的 Transact-SQLTransact-SQL 預存程序、使用者自訂的 Transact-SQLTransact-SQL 函數、觸發程序、計算資料行、CHECK 條件約束、檢視,或系統預存程序之類的系統物件。Displays the definition of a user-defined rule, default, unencrypted Transact-SQLTransact-SQL stored procedure, user-defined Transact-SQLTransact-SQL function, trigger, computed column, CHECK constraint, view, or system object such as a system stored procedure.

主題連結圖示 Transact-SQL 語法慣例Topic link icon Transact-SQL Syntax Conventions

語法Syntax

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

引數Arguments

[ @objname = ] '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. 名稱nvarchar(776) ,沒有預設值。name is nvarchar(776), with no default.

[ @columnname = ] 'computed_column_name' 是要顯示定義資訊的計算資料行的名稱。[ @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_namesysname,沒有預設值。column_name is sysname, with no default.

傳回碼值Return Code Values

0 (成功) 或 1 (失敗)0 (success) or 1 (failure)

結果集Result Sets

資料行名稱Column name 資料類型Data type 描述Description
TextText nvarchar(255)nvarchar(255) 物件定義Object definition

備註Remarks

sp_helptext 會顯示在多個資料列中建立物件所用的定義。sp_helptext displays the definition that is used to create an object in multiple rows. 每一個資料列都包含 255 個字元的 Transact-SQLTransact-SQL 定義。Each row contains 255 characters of the Transact-SQLTransact-SQL definition. 這個定義位在定義中的資料行sys.sql_modules目錄檢視。The definition resides in the definition column in the sys.sql_modules catalog view.

PermissionsPermissions

需要 public 角色的成員資格。Requires membership in the public role. 系統物件定義是公開顯示的。System object definitions are publicly visible. 凡具有下列任一權限的物件擁有者或承授者,都看得到使用者物件的定義:ALTER、CONTROL、TAKE OWNERSHIP 或 VIEW DEFINITION。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.

範例Examples

A.A. 顯示觸發程序的定義Displaying the definition of a trigger

下列範例會顯示 AdventureWorks2012AdventureWorks2012 資料庫中 dEmployee 觸發程序的定義。The following example displays the definition of the trigger dEmployee in the AdventureWorks2012AdventureWorks2012database.

USE AdventureWorks2012;  
GO  
EXEC sp_helptext 'HumanResources.dEmployee';  
GO  

B.B. 顯示計算資料行的定義Displaying the definition of a computed column

下列範例會顯示 AdventureWorks2012AdventureWorks2012 資料庫中的 TotalDue 資料表的計算資料行 SalesOrderHeader 的定義。The following example displays the definition of the computed column TotalDue on the SalesOrderHeader table in the AdventureWorks2012AdventureWorks2012 database.

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

以下為結果集:Here is the result set.

Text

---------------------------------------------------------------------

(isnull(([SubTotal]+[TaxAmt])+[Freight],(0)))

另請參閱See Also

Database Engine 預存程序(Transact SQL) Database Engine Stored Procedures (Transact-SQL)
OBJECT_DEFINITION (Transact-SQL) OBJECT_DEFINITION (Transact-SQL)
sp_help (Transact-SQL) sp_help (Transact-SQL)
sys.sql_modules (Transact-SQL) sys.sql_modules (Transact-SQL)
系統預存程序 (Transact-SQL)System Stored Procedures (Transact-SQL)