2

我想搜索列是否参与计算列表达式。

我想出了这个

SELECT 
    (select name 
     from sys.columns 
     where column_id = sys.sql_expression_dependencies.referencing_minor_id 
     and object_id = sys.sql_expression_dependencies.referencing_id) as [dependant_column]
FROM sys.sql_expression_dependencies
WHERE referencing_minor_id > 0 
    and referencing_class = 1 
    and referenced_class = 1 
    and object_name(referencing_id) = 'trns1'
    and referenced_minor_id = (select column_id 
                           from sys.columns 
                           where name = 'class1' 
                           and OBJECT_NAME(object_id) = 'trns1')

请帮忙。

4

1 回答 1

3

您想查看 sys.computed_columns 表:

select name, definition 
from sys.computed_columns

这是一个非常相似的问题:SQL Server: Computed Column defintions retrievable from Database?

可能还有更多的人在踢。

于 2012-11-01T08:17:22.460 回答