Ever wondered how to script the object’s definition directly in T-SQL (like you do in SSMS with “Script [object] as CREATE To”?
It is very simple because, as you would expected, this information is contained within SQL Server and it is easily accessible.
1 2 3 |
SELECT [definition] FROM sys.sql_modules WHERE OBJECT_ID = OBJECT_ID( '[schema].[object]') |