Rajanand Ilangovan
Rajanand Ilangovan

Rajanand Ilangovan

How to get all the computed columns in a database in SQL Server?

How to get all the computed columns in a database in SQL Server?

Rajanand Ilangovan's photo
Rajanand Ilangovan
·Apr 5, 2022·

1 min read

-- get the list of computed columns in a database
USE your_database_name_here;
GO

SELECT schema_name(o.schema_id) AS schema_name,
object_name(c.object_id) AS table_name,
c.name AS column_name,
type_name(user_type_id) AS data_type,
definition,
is_persisted
FROM sys.computed_columns c
INNER JOIN sys.objects o ON o.object_id = c.object_id
ORDER BY schema_name, 
table_name,
column_name

image.png

Impressum