question

Matt Whitfield avatar image
Matt Whitfield asked

Computed Column Meta-Data

Seeder question: In SQL Server 2000 I used to retrieve the source text for a computed column definition from syscolumns - however I am now using 2008 and I want to move to the newer system views - where do i now find the definition, as it doesn't seem to be in sys.sql_modules?

meta-datacomputed-column
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Bob Hovious avatar image
Bob Hovious answered

Try catalog view SYS.COMPUTED_COLUMNS.

declare @tableName Nvarchar(50)
set @tableName = 'dbo.SequenceControl'   -- change this for your purposes

select @tableName as TableName,sc1.name as columnName, isnull(sc2.definition,'') as def 
from sys.columns sc1
left join sys.computed_columns sc2 
     on sc2.[object_id] = sc1.[object_id] and sc2.[column_id] = sc1.[column_id]
where sc1.[object_ID] = object_id(@tableName)
order by sc1.column_id
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.