question

manishacumen avatar image
manishacumen asked

Finding objects/dependencies in a large number of SQL scripts.

Hi All, How to get the name of objects used in a complex sql script.I don't want to use sp_depends.I have around 13k scripts. I need to automate the process to find the object names. Any suggestion will be helpful.
scriptdependencyobjects
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Grant Fritchey avatar image
Grant Fritchey answered
If you're in 2008 or higher version of SQL Server you can use [sy.dm_sql_referencing_entities][1] or sys.dm_sql_referenced_entities to run queries against your code to see where objects are being used. From an automation stand point, this is really about your only choice. You can query the system tables directly to just search for strings, but it won't show you accurate references. [1]: https://msdn.microsoft.com/en-us/library/bb630351.aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.