TSQL to find computed column expression columns

Published 27 July 07 12:34 AM | SQL Master 

USE <dbname>;
GO
SELECT OBJECT_NAME(d.referenced_major_id) AS referenced_name
    ,COL_NAME(d.referenced_major_id, d.referenced_minor_id) AS referenced_columns
    ,OBJECT_NAME(referenced_major_id) AS dependent_object_name
    ,COL_NAME(d.object_id, d.column_id) AS dependent_computed_column
    ,cc.definition AS computed_column_definition
FROM sys.sql_dependencies AS d
JOIN sys.computed_columns AS cc
    ON cc.object_id = d.object_id AND cc.column_id = d.column_id AND d.object_id=d.referenced_major_id    
WHERE d.class = 1
ORDER BY object_name, column_name;
GO

 

Comments

# SSQA.net - SqlServer-QA.net said on July 27, 2007 2:23 PM:

USE &lt;dbname&gt;; GO SELECT OBJECT_NAME(d.referenced_major_id) AS referenced_name ,COL_NAME(d.referenced_major_id

Anonymous comments are disabled

About SQL Master

**__________________________________** SQL Server MVP, Sr. DBA & industry expert. - Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it. It is also a power and you will gain by sharing it.

Search

Go

This Blog

«July 2007»
SMTWTFS
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

Syndication