sqlserver循环生成连续密码的sql

--创建临时表用来存储生成的数据,以免出错
create table #tb(
passcode varchar(20),
useFlag smallint,
useResv char(1),
cycleTime datetime
)

declare @maxPasscode int

set @maxPasscode = 99230091


declare @i int

set @i = 0

while @i < 1000
begin
set @maxPasscode = @maxPasscode + 1
insert into #tb values( @maxPasscode,0,'N',null)
set @i = @i + 1
end

select * from #tb

insert into summitstorage.dbo.preconfpasscode select * from #tb

drop table #tb

select count(*) from summitStorage.dbo.preconfpasscode where length = 8 and useflag = 0

你可能感兴趣的:(sql)