----建立数据库 .....
----建立表 cardInfo cardId varchar(8) password varchar(6)
----直接在sql中跑下面的sql语句就行了。。一次3000个
go
declare @cardNum int -- number of card
declare @needNum int -- the number of card that you need
----- inite ---------
set @cardNum=0;
set @needNum=3000
yourNeed:
----------------- generate card -------------------
declare @cardId varchar(8) -- card id
declare @i int -- temp
----- card Id generate
cardId:
set @i=0
set @cardId=cast((rand()*100000000) as int)
set @cardId=right(@cardId+1000000000, 8)
if exists(select 1 from dbo.cardInfo where cardId=@cardId)
goto cardId
---- password generate
declare @j int
set @j=0
declare @password varchar(6) -- password
declare @type int -- type of bit of password(number or a\b\c..)
declare @ch char
declare @charASSIC int -- ASSIC of char
set @password=''
while(@j<6)
begin
/*random type*/
set @type= cast((rand()*10) as int)
if(@type>4) -- use number
begin
set @ch=convert(char,cast((rand()*10) as int))
set @password=@password+@ch
--print 'type'+convert(char,@type)+'ch'+@ch+' password:'+@password
end
else -- use a b c ...
begin
set @charASSIC=cast((rand()*27) as int)+96 -- generate a number between 97(a) and 122(z)
if(@charASSIC=96) set @charASSIC=@charASSIC+1
set @ch=char(@charASSIC)
set @password=@password+@ch
--print 'type'+convert(char,@type)+'ch'+@ch+' password:'+@password
end
set @j=@j+1
end
insert into cardInfo(cardId,password) values(@cardId,@password)
set @cardNum=@cardNum+1;
if(@cardNum<@needNum)
goto yourNeed