Thursday, 21 June 2018

How to find out tables used in the specific stored procedure

;WITH stored_procedures AS (
SELECT AS proc_name, AS table_name,
ROW_NUMBER() OVER(partition by, ORDER BY, AS row
FROM sysdepends d
INNER JOIN sysobjects o ON
INNER JOIN sysobjects oo ON
WHERE o.xtype = 'P')
SELECT proc_name, table_name FROM stored_procedures
WHERE row = 1 and proc_name='input_stored_procedure name'
ORDER BY proc_name,table_name   

No comments:

Post a Comment

Check if column exists or not in the SQL server

--method 1 IF EXISTS(SELECT 1 FROM sys.columns with (nolock)           WHERE Name = N'LoginName'           AND Object_ID = Objec...