declare @month int
set @month=1while @month<13
begin
insert into tblTest(monthField) values (@month)
set @month=@month+1
end

解决方案 »

  1.   

    create table test(aa int)declare @i int
    set @i = 1
    while @i <= 12
    begin
     insert test select @i
     set @i = @i+1
    end
    select * from testdrop table test
      

  2.   

    select top 12 dateadd(month,(select sum(1) from sysobjects where id<=a.id)-1,'2002-1-1') 时间 from sysobjects a
      

  3.   

    如果你只要1-12的数字
    select top 12 (select sum(1) from sysobjects where id<=a.id) 时间 from sysobjects a
      

  4.   

    create table test (
    m int
    )declare @i int
    set @i = 1
    while @i<=12
    begin
    insert into test values (@i)
    set @i = @i + 1
    endselect * from test