Here's a guest article by Nob Hill Software. http://www.nobhillsoft.com/
Much has been written about Query Execution Plans (we’ll call them QEPs), and how they can be used for analyzing how SQL Server interprets your TSQL code and what it does behind the scenes –
information you can use to do such things as find bottlenecks, build indexes where they might help, and generally improve the performance of your code.
Well, we have found more uses for it. There is more information in the QEP, information that’s not typically used, yet is highly useful and very easy to retrieve:
1. IS YOUR CODE BROKEN?
TSQL code can get ‘broken’ all the time. You might be referencing tables or columns that don’t exist.
They might have even existed at the time you wrote the procedure, but have been removed since, leaving your procedure ‘broken’ - It will raise an error next time its executed. How many of those do YOU have in your database?
Now, if a code is broken, SQL Server will let you know about that when attempting to retrieve its execution plan. Strictly speaking, this is not QEP information. Its information you will get while trying to get the QEP. And that is not the only way to get that information. But it’s the easiest.
2. WHAT ENTITIES ARE USED IN FOR WHAT OPERATION?
Among all the logical and physical operations, and effects on memory etc, QEP also contains the very basic information of what entities it is working with, and what it does on such entities. This information can be then used to build a basic ‘browser database’, which you can use to answer questions like: which code inserts to this table? I got data missing… which procedure removes records from here?
In order to get any SQL’s execution plan in SQL Server, all you need to do is:
set SHOWPLAN_ALL on
write your SQL here
set SHOWPLAN_ALL on
If you get an error, this means the stored procedure is broken, and the error would say why.
Otherwise, you can get the execution plan in a tabular format, and retrieve the specific entities used from it.
We put this functionality into one of our freebie products, Diana Lite. You can build the full ‘browser database’ out of the collection of any database’s SQL Code, then easily filter it and get to whatever you are looking for:
Sweet, Huh?
http://www.nobhillsoft.com/Freebies.aspx