It is almost impossible for a newid() to already exist ... so it should be enough to allocate a newid and then if you find that it DOES exist just loop round and allocate another one.
We don't bother. We have a unique index on the column so IF we were to try to add a GUID that already existed then the APP would fail with an error. It is so unlikely to ever happen that we are happy to terminate the program with a critical error in that situation.
I don't think that it can. Definitely possible to get a duplicate. Statistically impossible though. On the same machine then supposedly impossible because algorithm includes time (although I am not sure that is the case for new formulae). But, assuming time included, what about for the hour when the clocks go back in the Fall? Or some hardware issue with the clock ... or it being reset a smidgeon by SYNC with Time Server ...
GUIDs generated by TWO machines then definitely (albeit rate) evidence of duplicates.
On computers with poor implementations of GUID algorithm ... chances increase
Like I said, it is not something I worry about, but we do put a Unique Index on GUID columns just-in-case. If we have a GUID column we will likely be retrieving records based on it, so the Index will come in handy anyway, and the SQL Query Planner will appreciate the Unique attribute
That's an extraordinarily contradictory mix of quotes. First you say it's so rare you don't even bother to check at all ahead of time for a collision. Then you say it's too "risky" to check only once ahead of time if the actual insert will take a few seconds to occur! Huh??
We are relying on our Unique Index catching any error. We don't think it will ever happen, but we are happy that SQL terminates our action with an error if it does.
The O/P is generating a GUID and then testing that it does not exist in the database, and is then going to use it to INSERT - by which time [I am suggesting] some other user may have inserted a duplicate. The O/P is going to the trouble of checking that the GUID generated by NewID() does not exist, so I have presumed that avoiding DUPs is of critical importance.