Wednesday, March 7, 2012

How to find formula column from a table programmatically?

Hi,

I'm on SQL Server 2000, say, I have a table named [orders], how I find
if there is any column which has a formula in it? In other words, how
to identify formula column programmatically? I've looked at
information_schema.columns view for clue but to no avail.

Thanks.Thanks, John, yes, I got it with a slight twist, which might have been
intended by you. In the WHERE clause I ensures that COLUMNPROPERTY(
id ,name, 'ISComputed') is true. Also, since ComputedColumn is
introduced in SQL 2000, I make sure to check server version before
using this property.

Regards,

"John Bell" <jbellnewsposts@.hotmail.com> wrote in message news:<3f1169cc$0$18750$afc38c87@.news.easynet.co.uk>...
> Hi
> Something like the following may be what you require:
> CREATE TABLE TestComputed ( Id INT IDENTITY NOT NULL, ID2 as 2*Id , Col1
> char(1) )
> SELECT OBJECT_NAME(id), Name, COLUMNPROPERTY( id ,name, 'ISComputed')
> FROM SYSCOLUMNS
> WHERE OBJECT_NAME(id) = 'TestComputed'
>
> John
>
> "Doug Baroter" <qwert12345@.boxfrog.com> wrote in message
> news:fc254714.0307122105.31f3c396@.posting.google.c om...
> > Hi,
> > I'm on SQL Server 2000, say, I have a table named [orders], how I find
> > if there is any column which has a formula in it? In other words, how
> > to identify formula column programmatically? I've looked at
> > information_schema.columns view for clue but to no avail.
> > Thanks.|||Thanks, Erland.

Erland Sommarskog <sommar@.algonet.se> wrote in message news:<Xns93B8710A571B9Yazorman@.127.0.0.1>...
> Doug Baroter (qwert12345@.boxfrog.com) writes:
> > Thanks, John, yes, I got it with a slight twist, which might have been
> > intended by you. In the WHERE clause I ensures that COLUMNPROPERTY(
> > id ,name, 'ISComputed') is true. Also, since ComputedColumn is
> > introduced in SQL 2000, I make sure to check server version before
> > using this property.
> As far as I recall, computed columns were introduced in SQL7.

No comments:

Post a Comment