Do we have a sys table which holds the copy of entire stored procedure?

Viewed 32

Do we have a sys table which holds the copy of entire stored procedure?

Something similar to syscomments which holds the entire sp in a column? If not available, how to save the entire sp in a column?

1 Answers

Yes, the metadata table is called sys.sql_modules:

Returns a row for each object that is an SQL language-defined module in SQL Server, including natively compiled scalar user-defined function. Objects of type P, RF, V, TR, FN, IF, TF, and R have an associated SQL module.

Column definition

SQL text that defines this module. This value can also be obtained using the OBJECT_DEFINITION built-in function.

db<>fiddle demo


Another table is INFORMATION_SCHEMA.ROUTINES

SELECT ROUTINE_DEFINITION, *
FROM INFORMATION_SCHEMA.ROUTINES;

db<>fiddle demo2

Related