If we want to make some identiity value in sqlserver , we can use identity data type in a table.
However, there are some disadvantages on that style,
But , how to ?
Here we go
we can use
replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
to get time as char
result is: 20170210000222
And we can use
replace(CONVERT(uniqueidentifier,NewID(), 120 ),'-','')
to get random number conver to char. How about to make they together
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','') + replace(CONVERT(uniqueidentifier,NewID(), 120 ),'-','')
That result like 20170210000436590385B62DDD4D4B9ABB8009BDEDDD40
Then you can make it The result is unqiue and easy to management it.
Comments