I have a table with a list of invitations. Each invitation should contain an unique InviteCode. Example: 4BF8
I want to generate a dynamically a unique InviteCode. I mean, that that string does not exist in the table.
I have been using this SQL sentence to generate the random string:
select LEFT(newId(), 8)
I've thinking using something like:
select LEFT(newId(), 4) as myNewInviteCode WHERE NOT EXISTS
(SELECT InviteCode from Userconnections WHERE InviteCode = myInviteCode)
Any idea? suggestion?
Thanks!