Where is a script to list all tables/columns in a SQL Server 2008 R2 database that are not referenced in any stored procedure?
-
We have hundreds of report stored procedures that we are wanting to create a reporting only database and drop all columns that are not used by any of the stored procedures.
-
Answer:
There is no easy way to do this that I'm aware of for columns. You can pretty easily determine the tables that are needed as dependencies. Microsoft has scripts that do this: http://msdn.microsoft.com/en-us/library/ms345404.aspx
Grant Fritchey at Quora Visit the source
Other answers
By identifying the tables/columns used you can then get an unmatched result. For tables: SELECT Name FROM sys.procedures WHERE OBJECT_DEFINITION(OBJECT_ID) = [YourTableName] For columns it looks like Pinal Dave has a solution: http://blog.sqlauthority.com/2012/07/15/sql-server-find-column-used-in-stored-procedure-search-stored-procedure-for-column-name/
Preston Mesarvey
Related Q & A:
- What is the best practice for free space for a SQL server database drive?Best solution by Database Administrators
- How to Restrict Database for One User in SQL Server 2008 R2?Best solution by Database Administrators
- How to add primary key from multiple table as a foreign key in a table in sql server 2008?Best solution by stackoverflow.com
- How to restrict access to a sql server database from Azure?Best solution by Stack Overflow
- How do I connect to a SQL Server database?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.