sql 验证码生成和补位
时间:2021-07-01 10:21:17
帮助过:23人阅读
@a int = 0,
@b varchar(
10)
= ‘‘
CREATE TABLE #temp2 (
vcCode varchar(
10),
nStatus int
)
while(
@a < 10000)
begin
--随机数生成(不推荐)
--set @b = right(‘000‘+cast(ceiling(rand() * 10000) as varchar),4)
set @b = right(
‘000‘+cast(
@a as varchar),
4)
if not exists(
select null from #temp2
where vcCode
= @b)
begin
insert into #temp2
values(
@b,
11)
set @a = @a +1
end
end
insert into Table_a
select * from #temp2
order by newid()
sql 验证码生成和补位
标签:exist select values 随机数 val nbsp while bsp span