Creating A Unique Token 🔑

I have a personal project I am working on and I need to be able to create a unique token 10 characters) for each client. Then I need to populate each client with it’s unique token. I’m just confused on how to make this truly unique, any ideas? So far this is what I have, but it’s not unique because it doesn’t check to see if the value exists before it sets the uniqueTokenID.

alter table Clientele
	add uniqueTokenID VARCHAR(10) default SUBSTRING(CONVERT(varchar(255), NEWID()), 0, 10)
update dbo.Clientele
 SET uniqueTokenID = (SUBSTRING(CONVERT(varchar(255), NEWID()), 0, 10))

Note: I apologize if this is in the wrong section, I used my best judgment for the right selection. Also, I know this is kind of cringe with the way I did this, but this is why im asking for help (im more of a front-end person)

I think NEWID() is pretty much guaranteed to generate a unique identifier, I doubt you would need to do any comparison.

Looking at some documentation it says NEWID() is compliant with RFC4122 and likely anything new will use one of the later versions of uuid (like v4). So I’m guessing you would be very unlikely to run into duplication (technically not impossible, just highly improbable).

It’s weird because I did run into a duplicate with this and that’s why I made this post :frowning:

That doesn’t look like a full GUID/UUID. It should look something like this 6F9619FF-8B86-D011-B42D-00C04FC964FF.