Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if computed column is persisted?

How to check if computed column is persisted? (MS SQL Server)

like image 422
Alex Avatar asked Mar 11 '11 12:03

Alex


1 Answers

Computed column attributes are available in sys.computed_columns.

select * from sys.computed_columns where is_persisted = 1

is_persisted = 1 for the column being persisted, 0 otherwise.

You can link this back to sys.tables via the object_id e.g.

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

And change your where clause to include the table name / field name as appropriate to your scenario.

like image 149
Andrew Avatar answered Nov 01 '22 08:11

Andrew