How to find the tables being affected, the actually relationship, and type of query used in the or inside the stored procedure? I am making a drill down basically.
Loading
How to find the tables being affected, the actually relationship, and type of query used in the or inside the stored procedure? I am making a drill down basically.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
SenthilkumarRank #387 · 6.5K reputationPosted Apr 8, 2012, 5:59 PM EDT
There are ways to identify these things.
Relationship:
You can use the system stored procedure to identify the relationship for the particular table.
sp_depends Table_Name
Type of query used:
You need to search the particular text in the stored procedure.
For identify being tables affected, you can use the triggers on database.
http://www.mindstick.com/Articles/f7074849-0e9e-463b-a12d-f3d7a35b2785/?Trigger%20in%20SQL%20Server
MuthuMari MRank #5,738 · 288 reputationPosted Apr 8, 2012, 7:25 PM EDT
you can use SQL Server Profiler to trace your sql queries and stored procedures on the database.
pls refer this url to connet sql profiler
http://www.quackit.com/sql_server/tutorial/sql_profiler.cfm
http://msdn.microsoft.com/en-us/library/ms187929%28SQL.90%29.aspx
thanks
If this post is useful then mark it as "Accepted Answer"
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 8, 2012, 8:03 PM EDT
In SQL server there is one table that store relation ship "sysdepends".
Try....
SELECT o.name AS procname, oo.name AS tablename,
ROW_NUMBER() OVER(partition by o.name,oo.name ORDER BY o.name,oo.name) AS row
FROM sysdepends d
INNER JOIN sysobjects o ON o.id=d.id
INNER JOIN sysobjects oo ON oo.id=d.depid
WHERE o.xtype = 'P'
And o.name = 'Procedure Name'
hope this help.
David SmithRank #999 · 2K reputationPosted Apr 8, 2012, 9:26 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 8, 2012, 9:45 PM EDT
use following query that help you to find all table that are used in SP
SELECT o.name AS procname, oo.name AS tablename
FROM sysdepends d
INNER JOIN sysobjects o ON o.id=d.id
INNER JOIN sysobjects oo ON oo.id=d.depid
WHERE o.xtype = 'P'
hope this help.