gettingThereSlowly
gettingThereSlowly

Reputation: 143

how do I determine which objects use a specific table

I need to find/create the sql that will return any/all objects related to a specific table, be it another table or procedure, whatever is using the table in question. Is there a specific table I should be looking for or any specific parameters I should be using? I am a novice, I am using Microsoft SQL Server Management studio 2008 R2 Thanks in advance for any help/assistance offered.

Upvotes: 0

Views: 55

Answers (2)

Ben Thul
Ben Thul

Reputation: 32687

Check out sys.dm_sql_referencing_entities. Use it like so:

select * from sys.dm_sql_referencing_entities('schema.objectName', 'object')

Upvotes: 0

M.Stoop
M.Stoop

Reputation: 119

You can use the sp_depends system stored procedure.

http://technet.microsoft.com/en-us/library/ms189487.aspx

Example: you have a table USERS and wish to see what objects you should check before making changes:

EXEC sys.sp_depends 'USERS'

If you happen to own the Red-Gate dependency tracker, this takes a more visual approach which is easy to check the impact.

Upvotes: 1

Related Questions