Saturday, 16 January 2021

Generate or Create GUID random in MS SQL Server with datetime

 /////////////////// Sql

select LEFT(REPLACE(CONVERT(VARCHAR(255),NEWID()),'-',''),10)+RIGHT(REPLACE(CONVERT(VARCHAR(255),NEWID()),'-',''),10)+format(getdate(), 'yyyyMMddHHmmssfff')GUID


///////// Result


11F7A1525A049FB6145E20210116183025690

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...