Groups | Blog | Home
all groups > dotnet ado.net > may 2007 >

dotnet ado.net : Guid uniqueness and concurrency management.


William (Bill) Vaughn
5/31/2007 1:47:04 PM
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)
-----------------------------------------------------------------------------------------------------------------------

[quoted text, click to view]

BLUE
5/31/2007 9:21:49 PM
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.

Patrice
6/1/2007 6:56:36 PM
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...

---
Patrice

"BLUE" <blue> a écrit dans le message de news:
%23AJizm7oHHA.4652@TK2MSFTNGP02.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button