August 24, 2016 at 3:49 pm
is there anyway i can update a nvarchar field with unique 15 digit nvarchar ? i cant seem to find an answer online. Any clues guys.
August 24, 2016 at 7:22 pm
Yes but why are you using NVARCHAR to store "digits"? Also, you've not stated the full datatype for the column. NVARCHAR(???) ? And, what do you want to update it to and from?
--Jeff Moden
Change is inevitable... Change for the better is not.
August 25, 2016 at 9:26 am
Jeff,
It is a UserId field with i.e. userID nvarchar(15). We have to have a unique alphanumeric values for all userID's.
thanks,
August 25, 2016 at 10:10 am
Would this work?
LEFT(REPLACE(CAST(NEWID () AS NVARCHAR(MAX)), '-', '') , 15)
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
August 25, 2016 at 10:34 am
Alvin Ramard (8/25/2016)
Would this work?
LEFT(REPLACE(CAST(NEWID () AS NVARCHAR(MAX)), '-', '') , 15)
I'm not sure if that will return unique strings. Although, the chance for duplicates is low.
August 25, 2016 at 10:41 am
Luis Cazares (8/25/2016)
Alvin Ramard (8/25/2016)
Would this work?
LEFT(REPLACE(CAST(NEWID () AS NVARCHAR(MAX)), '-', '') , 15)
I'm not sure if that will return unique strings. Although, the chance for duplicates is low.
Good point Luis. A Unique constraint could easily prevent duplicates.
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply