标签:name declare span sql cas pre char font select
生成三位随机字母+12位数字
declare @CardCode varchar(50),@str varchar(50), @c int; select @CardCode=abs(CHECKSUM(NEWID())) set @c=12-LEN(@CardCode); select @str= FLOOR(rand()*POWER(10,@c)) set @CardCode=@CardCode+@str declare @sql nvarchar(400) ,@name varchar(50) ; select @name= char( cONVERT(NVARCHAR,CONVERT(INT,26*rand())+97) )+ CHAR( CONVERT(NVARCHAR,CONVERT(INT,rand()*26)+97) )+ CHAR( CONVERT(NVARCHAR,CONVERT(INT,rand()*26)+97) ) select @name+CAST( @CardCode as nvarchar(50))
下面这个是生成大写字母的
declare @sql nvarchar(400) ,@name varchar(50) ; select @name= char( cONVERT(NVARCHAR,CONVERT(INT,26*rand())+65) )+ CHAR( CONVERT(NVARCHAR,CONVERT(INT,rand()*26)+65) )+ CHAR( CONVERT(NVARCHAR,CONVERT(INT,rand()*26)+65) ) select @name
标签:name declare span sql cas pre char font select
原文地址:https://www.cnblogs.com/yangjinwang/p/9179300.html