.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Code Snippets >> SQL Query >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Query to Get the dependencies for given Table Name

Posted By:Lakhan Pal Garg       Posted Date: November 19, 2009    Points: 10    Category: SQL Query    URL: http://www.dotnetspark.com  

Following Query is used to get the dependencies for the given Table.
Suppose we need to check the dependencies for the table tbl_Customer

Sample Query:

DECLARE @Objectname varchar(100)
SET @Objectname='tbl_Customer'

SELECT O1.name,O2.name FROM sys.sql_dependencies D INNER JOIN Sys.Objects O1 ON O1.object_id=D.object_id
INNER JOIN Sys.Objects O2 ON O2.object_id=D.referenced_major_id
WHERE O1.name=@Objectname OR O2.name=@Objectname

Thanks & Regards
Lakhan Pal Garg


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend