Live Traffic Feed

Thursday, October 11, 2018

Generate 8 digit random alphanumeric string in sql server

Leave a Comment
For generate random alphanumeric string in sql server, use following query:


SELECT CAST((ABS(CHECKSUM(NEWID()))%10) as varchar(1)) + CHAR(ASCII('a')+(ABS(CHECKSUM(NEWID()))%25)) + CHAR(ASCII('A')+(ABS(CHECKSUM(NEWID()))%25)) + left(NEWID(),5)


This will return alphanumeric string with 8 digit.

If you want to use this query to sql server function then refer my another blog from following link:

Use NEWID() in sql server function
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment