2011-03-11 62 views
4

如何檢查計算列是否被保留? (MS SQL Server)如何檢查計算列是否被保留?

+0

有點相關,不直接。好讀:http://stackoverflow.com/questions/916068/sql-server-2005-computed-column-is-persisted – 2011-03-11 12:36:10

回答

9

計算列屬性在sys.computed_columns中可用。

select * from sys.computed_columns where is_persisted = 1 

is_persisted = 1表示持續存在,否則爲0。

您可以通過object_id將它鏈接回sys.tables。

select t.name, c.name 
from sys.tables t 
inner join sys.computed_columns c on c.object_id = t.object_id 
where c.is_persisted = 1 

然後將您的where子句更改爲包含適合您的方案的表名稱/字段名稱。