Grab our RSS feeds Follow us on Twitter Join our Facebook Group Connect with us on LinkedIn
myITforum.com, Powered by You.
you are not logged in

Articles

Newslinks

Links

Downloads

Site Services

Community Forums

Discussion Lists

Article Search

Newsletter

Web Blogs

FAQs

Live Support

myITforum TV

Take a Poll

Monthly Drawing

myITforum Network

User Group Directory

Our Partners

About Us

Register

Login

BRONZE PARTNER:

BRONZE PARTNER:



Industry News:




  Home : Articles : SMS 2.x print | email | | Forums |   print | email | | Blogs |   print | email | | Wiki |   print | email | | FAQs |   print | email | Article Search  
SQL Query To Find Table Dependencies


Bookmark and Share

By: Don Hite
Posted On: 12/6/2007

This article was Previously posted on Don Hite's Blog

Use this SQL script to return the table dependencies such as stored procedures for your database objects.

You need to change the XType value referenced in the query below to find any of the objects in the following chart:

C = Check Vonstraint
D = Default or Default Constraint
F = Foreign Key Constraint
L = Log
Fn = Scalar Function
If = Inlined Table Function
P = Stored Procedure
Pk = Primary Key Constraint
Rf = Replication Filter Stored Procedure
S = System Table
Tf = Table Function
Tr = Trigger
U = User Table
Uq = Unique Constraint
V = View

SQL Query:

Select Distinct
SysObjects.Name 'Table Name',
Procedures.Name 'Stored Procedure'

From SysObjects
Join (SysObjects Procedures
Join SysDepends
on Procedures.Id = SysDepends.Id)
On SysDepends.DepId = SysObjects.Id

Where SysObjects.XType = 'U'

-- Change XType Values here using chart above
And Procedures.XType = 'P'

Group by SysObjects.Name,
SysObjects.Id,
Procedures.Name

Order by SysObjects.Name Asc



  myITforum.com ©2010 | Legal | Privacy