共计 961 个字符,预计需要花费 3 分钟才能阅读完成。
// 生成 uuid 并转为小写
select LOWER(SUBSTRING(uuid,1,8)+’-‘+SUBSTRING(uuid,10,4)+’-‘+SUBSTRING(uuid,15,4)+’-‘+SUBSTRING(uuid,20,4)+’-‘+SUBSTRING(uuid,25,12))
from (select cast(NEWID() as varchar(36)) as uuid) s //ea52a7bb-a2aa-44b8-be28-5ebc64defcf9
// 获取时分秒
select DateName(hour,GetDate())+ DateName(minute,GetDate())+DateName(second,GetDate()) //143054
//1000-9999 随机数
select floor(9000*RAND()+1000)
// 日期格式化
select GETDATE() //2019-02-12 14:30:16.763
Select CONVERT(varchar(100), GETDATE(), 8) //10:57:46
Select CONVERT(varchar(100), GETDATE(), 12) //060516
Select CONVERT(varchar(100), GETDATE(), 20) //2006-05-16 10:57:47
Select CONVERT(varchar(100), GETDATE(), 21) //2006-05-16 10:57:47.157
Select CONVERT(varchar(100), GETDATE(), 23) //2006-05-16
Select CONVERT(varchar(100), GETDATE(), 24) //10:57:47
Select CONVERT(varchar(100), GETDATE(), 25) //2006-05-16 10:57:47.250
Select CONVERT(varchar(100), GETDATE(), 102)//2006.05.16
Select CONVERT(varchar(100), GETDATE(), 111)//2006/05/16
Select CONVERT(varchar(100), GETDATE(), 112)//20060516