[MSSQL] while 로 반복 작업하는 코드
DB&XML 2009. 5. 7. 00:57 |
declare @idx int
declare @account varchar(20)
declare @nickname varchar(20)
declare @account2 varchar(20)
declare @nickname2 varchar(20)
set @idx = 0
set @account = 'test'
set @nickname = 'Dummy'
while (1=1)
begin
if @idx > 9999 break;
set @account2 = @account + convert(varchar(4), @idx)
set @nickname2 = @nickname + convert(varchar(4), @idx)
print @idx
print @account2 + @nickname2
INSERT INTO [NDT].[dbo].[USERACCOUNT]
([ACCOUNT]
,[PASSWORD]
,[NICKNAME]
,[MONEY]
,[LOGINSTATE])
VALUES
(@account2
,'1'
,@nickname2
,0
,0)
set @idx = @idx + 1
end