Declare @I Int
Set @I=1
While @I<11
Begin
insert into shopuser (username,userpassword) values (@I,'123456');
Set @I=@I+1
End

解决方案 »

  1.   

    --insert into shopuser (username,userpassword) values ('1','123456');
    create table shopuser
    (
      username varchar(10) not null,
      userpassword varchar(20) not null,
    )Declare @iCount int
    Set @iCount=1
    While @iCount<11
    Begin
    insert into shopuser (username,userpassword) 
                           select @iCount,'123456';
    Set @iCount=@iCount + 1
    End
    select * from shopuserdrop table shopuser
    结果:
    1 123456
    2 123456
    3 123456
    4 123456
    5 123456
    6 123456
    7 123456
    8 123456
    9 123456
    10 123456
      

  2.   

    declare @i int
    set @i=1
    while @i<=10
    begin
    insert into shopuser (username,userpassword) values (@i,'123456')
    @i=@i+1
    end
    go