dbTalk Databases Forums  

What is the purpose of the ROWGUIDCOL property?

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss What is the purpose of the ROWGUIDCOL property? in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Sam Bendayan
 
Posts: n/a

Default What is the purpose of the ROWGUIDCOL property? - 12-04-2007 , 10:19 AM






Greetings,

What is the point of Microsoft defining a ROWGUIDCOL property that can
be attached to a 'uniqueidentifier' column? This is defined as a column
that is 'globally unique', but doesn't the uniqueidentifier datatype
already guarantee that? To make matters more confusing, they tell you
in Books Online to add a Unique constraint because ROWGUIDCOL does not
guarantee uniqueness...so what's the point?

Apparently the only functionality attached to this property is that only
one such column can exist per table and that it can be queried using the
$ROWGUIDCOL keyword in SQL.

Can anyone tell me the rationale for when to use this and when not to,
or what the purpose of this property is?

Thanks,

Sam Bendayan
DB Architect
Ultimate Software
sam.bendayan (AT) gmail (DOT) com

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #2  
Old   
Hugo Kornelis
 
Posts: n/a

Default Re: What is the purpose of the ROWGUIDCOL property? - 12-04-2007 , 02:57 PM






On 04 Dec 2007 16:19:48 GMT, Sam Bendayan wrote:

Quote:
Greetings,

What is the point of Microsoft defining a ROWGUIDCOL property that can
be attached to a 'uniqueidentifier' column? This is defined as a column
that is 'globally unique', but doesn't the uniqueidentifier datatype
already guarantee that? To make matters more confusing, they tell you
in Books Online to add a Unique constraint because ROWGUIDCOL does not
guarantee uniqueness...so what's the point?
Hi Sam,

Starting from the end:

* Having a column defined as uniqueidentifier with a default of NEWID()
or NEWSEQUENTIALID() does not by itself uniqueness. First, I believe
that there is some (extremely unlikely) chance that generated guid
values can be duplicates; second, SQL Server does not prevent you from
manually entering data in this column, overriding the default.

Other that that, explicitly declaring uniqueness in a column gives
several other benefits as well. It gives a wealth of information to the
optimzier regarding data distribution, it makes the column eligible as
the target of a foreign key constraint, and it automatically creates an
index that can be used to speed up queries accessing this column.


The point of setting the ROWGUIDCOL property is to enable you to use
$ROWGUID instead of the column name in a SELECT list. Frankly, I shudder
when I attempt to think of scenario's where this would be useful, since
it implies that you select from a table without knowing yourself what
column is used for what purpose. <shudder>

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis


Reply With Quote
  #3  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: What is the purpose of the ROWGUIDCOL property? - 12-04-2007 , 04:39 PM



Hugo Kornelis (hugo (AT) perFact (DOT) REMOVETHIS.info.INVALID) writes:
Quote:
The point of setting the ROWGUIDCOL property is to enable you to use
$ROWGUID instead of the column name in a SELECT list. Frankly, I shudder
when I attempt to think of scenario's where this would be useful, since
it implies that you select from a table without knowing yourself what
column is used for what purpose. <shudder
It's used a by several features in SQL Server. Merge replication is one.
The new FILESTREAM feature in SQL 2008 also requires the table have a
ROWGUIDCOL.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.