January 5, 2016 at 11:15 am
Folks
I know this can be done but I am not sure what system tables/views need to be accessed.
I want to get the stored proc name and stored proc definition in the form of a SQL statement
Select sp_name , sp_definition FROM ........
January 5, 2016 at 11:24 am
mw112009 (1/5/2016)
FolksI know this can be done but I am not sure what system tables/views need to be accessed.
I want to get the stored proc name and stored proc definition in the form of a SQL statement
Select sp_name , sp_definition FROM ........
For procedures, you can use this:
SELECT p.name, m.definition
FROM sys.procedures p
JOIN sys.sql_modules m ON p.object_id = m.object_id
For other objects, you can change the sys.procedures view to sys.objects.
January 5, 2016 at 11:39 am
Piling on, here is the short disco version
😎
SELECT OBJECT_DEFINITION(OBJECT_ID(N'[schema_name].[object_name]'));
January 5, 2016 at 10:01 pm
USE AdventureWorks;
GO
SELECT definition
FROM sys.sql_modules
WHERE object_id = (OBJECT_ID(N'AdventureWorks.dbo.uspLogError'));
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply