时间:2021-07-01 10:21:17 帮助过:2人阅读
数字转换成字符串:把100转换成字符串
CAST(100 as varchar)
数字转换成字符串,并在前面补0,下面表示共6为数
right(‘000000‘+CAST(100 as varchar),6)
随机生成200以内的随机整数
select CAST(RAND()*200 as int)
随机生成个位数
select CHAR(ROUND(RAND() * 9+48,0))
生成有序字符串,前面是年月日时分秒,后三位是随机数
DECLARE @rand NVARCHAR(16) set @rand = REPLACE(CONVERT(NVARCHAR(16), GETDATE(), 120), ‘-‘, ‘‘); SET @rand = REPLACE(@rand, ‘ ‘, ‘‘); SET @rand = REPLACE(@rand, ‘:‘, ‘‘); SET @rand = @rand + CAST(FLOOR ((RAND() * 900 + 100)) AS NVARCHAR(3)); PRINT @rand
SQL_批量插入数据
标签: