Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
What is the Sql Query to find Stored procedure called for which all tables in Sql server 2005?
Posted

1 solution

SQL
----Option 1
SELECT DISTINCT so.name
FROM syscomments sc
INNER JOIN sysobjects so ON sc.id=so.id
WHERE sc.TEXT LIKE '%tablename%'
----Option 2
SELECT DISTINCT o.name, o.xtype
FROM syscomments c
INNER JOIN sysobjects o ON c.id=o.id
WHERE c.TEXT LIKE '%tablename%'
 
Share this answer
 
Comments
Rahul 105 12-Feb-14 0:09am    
Is it possible to get SPs with exact table name. If use LIKE (rOLES,rOLE_USER ETC RELATED SPS TO THOSE WILL COME)
SELECT DISTINCT so.name
FROM syscomments sc
INNER JOIN sysobjects so ON sc.id=so.id
WHERE sc.TEXT ='tablename'
But no Sp coming in above way.
Prasad Avunoori 12-Feb-14 0:34am    
I didn't get you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900