--Table 생성
Create Table Lotto
(Num int, Cnt BigInt)
--초기화
Declare @Num int
Set @Num=0
While @Num<45 Begin
Set @Num=@Num+1
Insert Lotto values(@Num,0)
End
-- 1부터 45까지 들어갔는지 검사
Select * from Lotto
/*
로또 복권 돌리는 프로그램
이상하다 밀리세컨드가 항상 뒤에 숫자가 일정하다...ㅠ.ㅠ
45 이하는 15개 밖에 돌지 않는다..
SQL 버그 인거 같다...ㅠ.ㅠ
*/
Declare @ii int
Declare @Num int
Set @ii=1
While @ii<8145000 Begin
Set @Num=Cast(Right(Cast(RAND(Datepart(ms,GetDate())) as varchar(30)),2) as Int)
if @Num<46 Begin
Set @ii=@ii+1
Update Lotto Set Cnt=Cnt+1 where Num=@Num
End
End