Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin.
Search for scripts directly from SSMS, and instantly access any saved scripts in your
SSC briefcase from the favorites tab.
Download now (direct download link)
Thank this author by sharing:
By Rhett Clement,
Wrote this to analyze the tables that are contained in a view. The problem I had with the INFORMATION_SCHEMA.VIEW_COLUMN_USAGE view is that if one view queries another it reports the view as the Base Table, not the actual database table the data comes from. Considering that this is a legal column definition in a view "1 As Id" then we can see why INFORMATION_SCHEMA doesn't attempt to dig down and tell us where that data came from, since the correct answer could be NULL.
But there are so many times when are views are 'honest' queries between multiple related tables and the occasional view. So if that's what you have this may be a useful way for you to uncover the tables that made up your view, without individually looking at the dependencies visualizer for each view or spending $$$ on software to do that for us. This query attempts to assist in that situation. I say attempts because it is not heavily tested and has limitations as I've hinted at above.
Also includes two other queries that show different summaries of the same data. Intended as an analysis query not something to use in a prodcution app. Requires SQL 2005 or higher. Written on SQL 2005.
I imagine community members will be able to point out additional issues or enhancements. I welcome your feedback.
receiving an error when attempting to add a leading character to a already existing string
In this document I will attempt to talk you through writing your first very simple DAX queries. For ...
Errors created when attempt to use a Computer Column in Query
There are certain key words in a T-SQL query than cannot be parameterized, including
the TOP statem...
Yesterday we had a user receiving the infamous failed login attempt error (no, that's not a valid IP...