Want to script all objects that depend on SQL Server table

View Dependecies displays all objects that depend on a table in SQL Server. Now, how can I use SSMS to script all of these objects in one command? Is there a free tool that does this?

+3
source share
2 answers

You can try this link Understanding SQL Dependencies First

Secondly, you have several options for checking dependencies

using the sql_expression_dependencies table to see the dependence of X on Y, run the following query.

SELECT * 
FROM sys.sql_expression_dependencies 
WHERE referencing_id = OBJECT_ID('X')
    AND referenced_id = OBJECT_ID('Y')
    AND referenced_schema_name = 'dbo'
    AND referenced_entity_name = 'Y'
    AND referenced_database_name IS NULL
    AND referenced_server_name IS NULL;

syscomments, syscomments SQL Server SQL , , default, trigger, CHECK DEFAULT, . ! SQL

SELECT *
FROM syscomments 
INNER JOIN sysobjects sysobj ON syscomments.id = sysobj.id
WHERE charindex('your object to check', text) > 0 

sp_depends, , : , , .

EXEC sp_depends @objname = N'your object to check'
+6

SSMS SMO . DependencyWalker, . , SMO script out Scripter ( SSMS script).

+1

Source: https://habr.com/ru/post/1723135/


All Articles