SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Locate specific columns used in procs

By Damien Alvarado, 2008/01/24

Total article views: 657 | Views in the last 30 days: 8

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.

USE [AdventureWorks]
GO

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

GO

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.

 

Enjoy!

By Damien Alvarado, 2008/01/24

Total article views: 657 | Views in the last 30 days: 8
Your response
 
 
Related tags

Administration    
Automation    
 
Related content

How do you make SQL Server 2000 listen...

By Steve Jones | Category: Administration
(not yet rated) | 3,986 reads

How do you increase the number of SQL...

By Steve Jones | Category: Administration
(not yet rated) | 3,698 reads
Like this? Try these...

Generate Create FK-indexes

By Johan Bijnens | Category: Indexing
(not yet rated) | 490 reads

Using DDL Trigger

By Renu Mehta | Category: DDL Triggers.
| 747 reads
Already registered?  

Free registration required

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com