How to check if computed column is persisted? (MS SQL Server)
            Asked
            
        
        
            Active
            
        
            Viewed 4,582 times
        
    6
            
            
        - 
                    Somewhat related, not directly. Good read : http://stackoverflow.com/questions/916068/sql-server-2005-computed-column-is-persisted – Saurabh Gokhale Mar 11 '11 at 12:36
 
2 Answers
11
            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.
        Andrew
        
- 26,629
 - 5
 - 63
 - 86
 
0
            
            
        Necromancing. 
If you need all columns, or just the computed columns, or just the persisted computed columns, you can do it with one script:
SELECT * 
FROM sys.columns AS sysc
LEFT JOIN sys.computed_columns AS syscc 
    ON syscc.object_id = sysc.object_id 
    AND syscc.name = sysc.name 
WHERE (1=1) 
AND sysc.is_computed = 1 -- optional 
AND is_persisted = 1  -- optional 
        Stefan Steiger
        
- 78,642
 - 66
 - 377
 - 442