How to find the dependencies of a field in all tables in SQl





Dependncies of a field in all tables in SQL.

If we want to find the dependencies of an SP or Table. there is an option in SQL,where we need to right click on the particular Table and view dependencies
We get all the dependencies like SP’s, views, triggers etc.

However to find the dependency of a particular field, we can use the script given below.

Sample of Dependency Script:

Implementation


SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%FieldName%'
ORDER BY schema_name, table_name;

HappyCoding ! 😉

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: