Sunday, February 26, 2012

exists rowguidcol on table?

Hi there
I have a table, which I want to alter and add a rowguid. Before I add this
rowguid to one of my column, then I want to be sure that the table does not
already have such a column. Therefore I was wondering how I can investigate
whether the table has a rowguid or not by using the composition below.
if exists (select 1 from ...)
begin
end
I know it is possible to clarify if an identity is configured to Not For
Replication or not by using the colstat and thought it might be possible to
investigate for the rowguidcol in same way, but I can't find any references
about how it is done neither in the official documentation nor at any news
groups and other unofficial references.
I hope for a soon reply on this.
Thanks in regards,
Jessuse: IF (OBJECTPROPERTY(OBJECT_ID(N'tablename'),
'TableHasRowGuidCol') = 1)
instead of: IF EXISTS (SELECT 1 FROM ...)
"languy" wrote:

> Hi there
> I have a table, which I want to alter and add a rowguid. Before I add this
> rowguid to one of my column, then I want to be sure that the table does no
t
> already have such a column. Therefore I was wondering how I can investigat
e
> whether the table has a rowguid or not by using the composition below.
> if exists (select 1 from ...)
> begin
> end
> I know it is possible to clarify if an identity is configured to Not For
> Replication or not by using the colstat and thought it might be possible t
o
> investigate for the rowguidcol in same way, but I can't find any reference
s
> about how it is done neither in the official documentation nor at any news
> groups and other unofficial references.
> I hope for a soon reply on this.
> Thanks in regards,
> Jess
>
>|||You can do this:
if exists(select 1 from syscolums where
columnproperty(id,name,'IsRowGuidCol')=1
and object_name(id)='yourtable')
print 'you betcha'
-oj
"languy" <jn@.online.stofanet.dk> wrote in message
news:epGr6$YFFHA.2180@.TK2MSFTNGP10.phx.gbl...
> Hi there
> I have a table, which I want to alter and add a rowguid. Before I add this
> rowguid to one of my column, then I want to be sure that the table does
> not already have such a column. Therefore I was wondering how I can
> investigate whether the table has a rowguid or not by using the
> composition below.
> if exists (select 1 from ...)
> begin
> end
> I know it is possible to clarify if an identity is configured to Not For
> Replication or not by using the colstat and thought it might be possible
> to investigate for the rowguidcol in same way, but I can't find any
> references about how it is done neither in the official documentation nor
> at any news groups and other unofficial references.
> I hope for a soon reply on this.
> Thanks in regards,
> Jess
>|||It works. :-)
Thanks a lot.
Regards,
Jess
"oj" <nospam_ojngo@.home.com> wrote in message
news:eu9Z4ZZFFHA.2572@.tk2msftngp13.phx.gbl...
> You can do this:
> if exists(select 1 from syscolums where
> columnproperty(id,name,'IsRowGuidCol')=1
and object_name(id)='yourtable')
> print 'you betcha'
>
> --
> -oj
>
> "languy" <jn@.online.stofanet.dk> wrote in message
> news:epGr6$YFFHA.2180@.TK2MSFTNGP10.phx.gbl...
>

No comments:

Post a Comment