Guid uniqueness and concurrency management.

  • Thread starter Thread starter BLUE
  • Start date Start date
B

BLUE

A GUID is a 128-bit integer (16 bytes) that can be used across all computers
and networks wherever a unique identifier is required.

There is a very low probability that the value of a new Guid is all zeroes
or equal to any other Guid.

From MSDN we know that there is a possibility to have two equal Guid.

I have two or more apps syncing their data with a db through a Web Service
and I cannot rollback synchronization beacause of a field was already
inserted.
I've a varchar field where I put the ID of an RFID tag, but if the app user
do not want to use this ID I'll generate it automatically with C# NewGuid
method converting the guid to an alphanumeric string without dashes (so it
is consistent with RFID ID).
It's good to do a loop until the insertion goes well?


How can I implement the "no insert" paradigm: if I want to create N
pre-filled rows that will be used by a "client application instance" I can
only do that if I set an Identity column but how to do that if I want to
insert manually the primary key values as stated above?


Thanks,
Luigi.
 
NewID() http://msdn2.microsoft.com/en-US/library/aa276822(SQL.80).aspx

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
 
In addition to William's response, IMO looping is unneeded in practice (you
meant to avoid a collision between GUIDs ?). Uniqueness is not a
mathemathical guarantee but it is AFAIK such a low probability that
basically it won't happen during your lifetime...

So mathematically it could happen (from wikipedia the probability is 1 on a
quintillion). For us mere mortals, it won't happen...
 
Back
Top