SQL code to open a stored procedure and read it in SQL Server

I use an interface that allows me to use only SQL commands. The database is SQL Server. Now I need to open the stored procedure and read what is inside it. What is an SQL command to open a stored procedure for reading? Thanks.

+6
source share
4 answers
SELECT definition FROM sys.sql_modules WHERE object_id = OBJECT_ID('YourSchemaName.YourProcedureName') 
+13
source
 sp_helptext 'dbo.myStoredProc' 
+5
source
 SELECT OBJECT_DEFINITION(OBJECT_ID('dbo.myStoredProc')) 

Note: subject to Visibility of metadata and SEE DEFINITION of the right

+4
source
 SELECT TEXT FROM syscomments WHERE id = (SELECT id FROM sysobjects WHERE name = '<NAME>') ORDER BY colid 
+1
source

Source: https://habr.com/ru/post/889036/


All Articles