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 Damien Alvarado,
Ever inherit a DB and wonder how many procs/views/triggers are referencing a column you have to make a DDL change to? You can change from VARCHAR(10) to VARCHAR(100), and everything looks cool until people start complaining about data being truncated. Where is that sp parameter definition that is truncating the data? This should help reduce your search efforts.
sp_depends shows you affected objects by table but not by column so I wrote this to show me where a particular column is getting used.
Also since sp_depends may not return all related procs I put a flag in to basically search all procedures.
Here is a sample call against the AdventureWorks DB.
DECLARE @return_value int
EXEC @return_value = [dbo].[LocateAffectedProcedures] @in_TableName = N'HumanResources.Employee', @in_Use_spDepends = FALSE, @in_ColumnName1 = N'LoginId'
SELECT 'Return Value' = @return_value
When you see the output you will see that the column is used in only one Stored Procedure and which lines it is used on. sp_depends returns 18 entries and searching through them all would be a bummer.
Full text search - No Data Return
This article demonstrates Data Profiling Functional Dependency
sp_depends may not always return accurate information
Most experienced DBAs know that sysdepends is not very reliable, so how can you find the dependencie...
Search for a string value within columns of data types CHAR, NCHAR, NTEXT, NVARCHAR, TEXT, VARCHAR, ...