要求变量A以下列形式变化:
0,110,230,360,500,650......谢谢赐教!

解决方案 »

  1.   

    --len=100select top 100 id=identity(int,110,10)
    into #t
    from syscolumns a,syscolumns b
    select [a]=0
    union all
    select [a]=(select sum(id) from #t where id<=t.id)
    from #t tdrop table #t/*
    a           
    ----------- 
    0
    110
    230
    360
    500
    650
    810
    980
    1160
    1350
    1550
    1760
    1980
    2210
    2450
    2700
    2960
    3230
    3510
    3800
    4100
    4410
    4730
    5060
    5400
    5750
    6110
    6480
    6860
    7250
    7650
    8060
    8480
    8910
    9350
    9800
    10260
    10730
    11210
    11700
    12200
    12710
    13230
    13760
    14300
    14850
    15410
    15980
    16560
    17150
    17750
    18360
    18980
    19610
    20250
    20900
    21560
    22230
    22910
    23600
    24300
    25010
    25730
    26460
    27200
    27950
    28710
    29480
    30260
    31050
    31850
    32660
    33480
    34310
    35150
    36000
    36860
    37730
    38610
    39500
    40400
    41310
    42230
    43160
    44100
    45050
    46010
    46980
    47960
    48950
    49950
    50960
    51980
    53010
    54050
    55100
    56160
    57230
    58310
    59400
    60500
    */
      

  2.   

    declare @i int,@num int,@tem int
    set @i = 0
    set @num = 0
    while(@i<10)
    begin if @i = 0
    print '0'
    else
    begin
    set @tem = @i *10 + 100
    set @num = @num + @tem
    print '@num='+cast(@num as varchar(20))
    end 
    set @i = @i + 1
    end