创建唯一标识的方法~16位唯一标识
SELECT LTRIM(STR(CONVERT(varchar(100), GETDATE(), 112)))+right(cast(power(10,6)
as varchar)+ISNULL( SUBSTRING(MAX(W_ID),9,6)+1,1),6)+right(cast(power(10,6)
as varchar)+datepart(Second,getdate()),2)FROM W_INFO
WHERE CONVERT(varchar(100), INSERT_DATE, 112) = CONVERT(varchar(100), GETDATE(), 112)
示例:2014032500000125
SELECT LTRIM(STR(CONVERT(varchar(100), GETDATE(), 12)))+right(cast(power(10,8)
as varchar)+ISNULL( SUBSTRING(MAX(USER_MSG_ID),7,8)+1,1),8)+right(cast(power(10,8)
as varchar)+datepart(Second,getdate()),2)FROM USER_MSG
WHERE CONVERT(varchar(100), INSERT_DATE, 12) = CONVERT(varchar(100), GETDATE(), 12)
示例:1403250000000124