Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 14th, 2005, 04:26 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default Stored procedure dependancy

Hi all,

Is there anyway, I can determine the tables and views accessed by a stored procedure ?

I have to create a dependancy list of stored procedures and tables / views of a database containing more than 1000 SPs. I am looking for an automatic way in which I can do this.

thanks

Madhu
 
Old December 14th, 2005, 12:20 PM
Authorized User
 
Join Date: Sep 2005
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default

use pubs
exec sp_depends 'byroyalty'

use northwind
exec sp_depends 'dbo.CustOrdersDetail'

or take a look at the sysdepends tables


“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" -- http://sqlservercode.blogspot.com/
 
Old December 15th, 2005, 12:21 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Thank you very much. You helped me save a lot of time. Also taught me a smart technique.

One doubt. I have an SP which just fetches all records from a table depending on a condition. When I run sp_depends on this SP, it gives the list of display columns mentioned in the query. However, the "selected" column in the result is "no" always. Shouldn't it be yes for those columns which are selected in the query?

I am using SQL Server 2000.

Thanks

Madhu
 
Old December 23rd, 2005, 05:41 PM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 146
Thanks: 0
Thanked 1 Time in 1 Post
Default

There a couple of problems with relying on sysdepends
1) If you truncate a table in a stored procedure but don't make any other reference to it then there is no dependency
2) If when you modify views, functions, tables, and stored procedures you drop and then create them, you will inevitably eliminate some of the depenency information unless you happen to recreate things in just the right order.
see http://www.sqlservercentral.com/colu...pendencies.asp


David Lundell
Principal Consultant and Trainer
www.mutuallybeneficial.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedure jezywrap SQL Server ASP 1 January 3rd, 2007 12:29 AM
stored procedure kdm260 SQL Server 2000 2 June 19th, 2006 04:45 PM
Help About Stored Procedure zhuge6 BOOK: ASP.NET Website Programming Problem-Design-Solution 3 May 20th, 2005 09:27 AM
Stored Procedure help flyin SQL Server 2000 4 August 3rd, 2004 07:37 AM
C# and stored procedure Msmsn C# 1 August 26th, 2003 11:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.