SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to trace/profile for references to tables when sp_executesql() is used extensively?


How to trace/profile for references to tables when sp_executesql() is used extensively?

Author
Message
Greg J
Greg J
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1371 Visits: 750
I've been tasked with trolling for references to tables on a particular server/database. We're in the process of moving most of the data to a new machine, but the migration isn't well documented (or executed).

It's my suspicion that a lot of the jobs and processes still running on the old box are in vain.

I'd like to capture all table references in that database over the span of say, 45 days, but PLENTY of code is executed using sp_executesql().

Further, I've found that when stores procs are called, the code shown in SQL Profiler stops well before the entire definition of the sproc, potentially leaving out some references.

Can someone please help me work around these shortfalls with the Profiler? Is there a better approach without incurring too much overhead?

Thanks in advance SSC!
Grant Fritchey
Grant Fritchey
SSC Guru
SSC Guru (99K reputation)SSC Guru (99K reputation)SSC Guru (99K reputation)SSC Guru (99K reputation)SSC Guru (99K reputation)SSC Guru (99K reputation)SSC Guru (99K reputation)SSC Guru (99K reputation)

Group: General Forum Members
Points: 99155 Visits: 33014
Profiler won't show the code from a stored proc if you're capturing execution calls. It will only show the code if you're capturing statement calls, which you don't want to do.

You'll need to combine the work. Capture all the calls using Profiler out to file. Then input that to a table where you can parse out the sql statements to get the ad hoc statements and each of their table references. Then you can query the databases directly to get table references from within the stored procedures (although, remember, some stored procs will directly reference the tables, others will build ad hoc statements internally).

In short, this is a huge undertaking.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search