Click here to Skip to main content
15,891,734 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

I want list of all computed columns and their formula using sql script.
I can able to find the list of computed columns but how can i get their formula.

SQL
select * from syscolumns where iscomputed=1


Above script gives me all computed columns. but how can i get formula of computed columns.
Posted
Updated 5-Sep-12 11:14am
v2
Comments
_Amy 12-Aug-12 6:51am    
Which kind of formula?
Andrei Straut 5-Sep-12 17:17pm    
I believe by "formula" he actually means how the columns are in fact computed. And of that, I have no idea

1 solution

Method 1)
SQL
SELECT [name], [definition]
FROM sys.Computed_columns


Method 2) with table name
SQL
SELECT obj.[name] AS [TableName], col.[name] AS [ColumnName], col.[definition] AS [Formula]
FROM sys.Computed_columns AS col
    INNER JOIN sys.objects AS obj ON col.object_id = obj.object_id
ORDER BY obj.name, col.name


Source: http://www.sqlservercentral.com/Forums/FindPost1114774.aspx[^]
 
Share this answer
 
Comments
fjdiewornncalwe 28-Sep-12 22:49pm    
+5. Excellent find. I learned something today.
Maciej Los 29-Sep-12 6:00am    
Thank you, Marcus ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900