Wednesday, 15 July 2020

How to generate alpha numeric random numbers using function in MS SQL Server

///////////// Sql query


SELECT LEFT(REPLACE(CONVERT(VARCHAR(255),NEWID()),'-',''),10)+RIGHT(REPLACE(CONVERT(VARCHAR(255),NEWID()),'-',''),10)


--------------- for more secure string

SELECT LEFT(REPLACE(CONVERT(VARCHAR(255),NEWID()),'-',''),4) + RIGHT(REPLACE(CONVERT(VARCHAR(255),NEWID()),'-',''),4) +
LEFT(REPLACE(CONVERT(VARCHAR(255),NEWID()),'-',''),4) +
RIGHT(REPLACE(CONVERT(VARCHAR(255),NEWID()),'-',''),4)
--------------- Result

A6A1B0FA27A405B38515

CBB8E0390AF48984


No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...