Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search SQL Server 2005... 1

Status
Not open for further replies.

bmgmzp

Programmer
Aug 18, 2006
84
US
Lets say I have the name of a StoredProcedure, View, or the name of a field in a Table... How can I search SQL Server 2005 and determine if the stored procedure, view or field is being used anywhere else?

Thanks
 
This isn't exactly what you are looking for (because it doesn't handle the columns within a table).

sp_depends '[!]Tablename[/!]'

Replace table name with view name and/or stored procedure name.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
you can also use the INFORMATION_SCHEMA view.

For example, If you looking to see if a store procedure references a column use this..

Code:
select *
from INFORMATION_SCHEMA.ROUTINES
where ROUTINE_TYPE='PROCEDURE'
AND ROUTINE_DEFINITION like '% you search value%'

use this to find columns

Code:
select * 
from information_schema.columns 
where column_name = 'ProductID'




- Paul
- If at first you don't succeed, find out if the loser gets anything.
 
Those methods will tell you if the object is referenced by another object. However you also need to monitor your users directly and see if they are accessing the object directly. This would be done via SQL Profiler.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top