Labels

Friday, December 30, 2011

How to use the object_definition system function?

Execute the following Microsoft SQL Server Transact-SQL (T-SQL) script in Management Studio (SSMS) Query Editor, SQLCMD or other client software to demonstratate the use of object_id, object_schema_name, object_name and object_definition system functions:

/*

OBJECT_DEFINITION applies to the following object types: 
C = Check constraint
D = Default
P = SQL stored procedure
FN = SQL scalar function
R = Rule
RF = Replication filter procedure
TR = SQL trigger
IF = SQL inline table-valued function
TF = SQL table-valued function
V = View
*/

USE AdventureWorks2008; 

SELECT object_id ('HumanResources.uspUpdateEmployeeHireInfo')

GO

-- 87671360 

SELECT object_schema_name(87671360),object_name(87671360)

GO

-- Returns object create statement

SELECT object_definition(87671360)

GO

No comments:

Post a Comment