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.
go
alter table Clientele
add uniqueTokenID VARCHAR(10) default SUBSTRING(CONVERT(varchar(255), NEWID()), 0, 10)
go
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)