T-SQL:
Declare @CurrentDate varchar(100)
Declare @Ext uniqueidentifier = NewID()
Set @CurrentDate = RTRIM(CONVERT(char(10), GetDate(),112)) + '_' + REPLACE(CONVERT(VARCHAR(8), GETDATE(), 108),':', '') +'_'+ CONVERT(varchar(100),(select LEFT(@Ext,8)))
Select @CurrentDate
Example Output:
20170529_203005_6B73B35D
Y 2017 M 05 D 29 T 8:30:05PM
Resources:
NEWID (Transact-SQL)
|
|
|
|
|