Computed Columns

  • Please, I want to know how I can get the Computed column definition of a certain table, I mean

    the entire formula that the computed column contains.

    Thanks for the help,

    p.s: I know how to get it by Management Studio, I want to know by script or system views.

  • You can use the following query:

    SELECT syscolumns.name, syscomments.text

    FROM sysobjects, syscomments, syscolumns

    WHERE sysobjects.id = syscolumns.id AND

    syscolumns.id = syscomments.id AND

    syscolumns.colid = syscomments.colid AND

    sysobjects.name = 'XYZ' AND

    syscolumns.iscomputed = 1

    XYZ represents the name of the column you're looking for.

    I retrieved this from http://www.sqlservercentral.com/articles/Administration/queryingsystemtables/1906/

    Eli

  • It didn't work for SQL Server 2005, maybe your query is designed just for sql 2k.

  • I just ran it in SQL Server 2005 and it worked. What happens when you run it?

  • My bad, It worked fine...

    Thanks a lot man..

  • Hey,

    I gotta a problem, my query is returning duplicated lines with different texts for each table.

    210240265951 ([dbo].[GetInscricao]([Inscricao], [Tributo], 1))

    210240265961 ([dbo].[GetInscricao]([Inscricao], [Tributo], 0))

    What means number column which is filled by 5 and 6 ??, I think that's the point!!

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply