Search code examples
sql-server-2008persistencecalculated-columns

How to check if computed column is persisted?


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


Solution

  • 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.