declare @t table(num int)
insert into @t select 1 union select 3 union select 4 union select 6 union select 8 select
    a.num*100+b.num*10+c.num
from
    @t a,@t b,@t c

解决方案 »

  1.   

    create table t (n smallint)
    go
    insert t select 1 union select 3  union select    4   union select    6  union select     8select ltrim(t1.n) + ltrim(t2.n)+ltrim(t3.n) 
    from t t1,t t2,t t3 
    where   t1.n<=t2.n
       and t2.n<=t3.n 
    drop table t/*
                      
    ------------------ 
    111
    113
    114
    116
    118
    133
    134
    136
    138
    144
    146
    148
    166
    168
    188
    333
    334
    336
    338
    344
    346
    348
    366
    368
    388
    444
    446
    448
    466
    468
    488
    666
    668
    688
    888(所影响的行数为 35 行)
    */
      

  2.   

    如果去掉条件create table t (n smallint)
    go
    insert t select 1 union select 3  union select    4   union select    6  union select     8select ltrim(t1.n) + ltrim(t2.n)+ltrim(t3.n) 
    from t t1,t t2,t t3 
    --where   t1.n<=t2.n
     --  and t2.n<=t3.n 
    drop table t/*
                      
                       
    ------------------ 
    111
    131
    141
    161
    181
    113
    133
    143
    163
    183
    114
    134
    144
    164
    184
    116
    136
    146
    166
    186
    118
    138
    148
    168
    188
    311
    331
    341
    361
    381
    313
    333
    343
    363
    383
    314
    334
    344
    364
    384
    316
    336
    346
    366
    386
    318
    338
    348
    368
    388
    411
    431
    441
    461
    481
    413
    433
    443
    463
    483
    414
    434
    444
    464
    484
    416
    436
    446
    466
    486
    418
    438
    448
    468
    488
    611
    631
    641
    661
    681
    613
    633
    643
    663
    683
    614
    634
    644
    664
    684
    616
    636
    646
    666
    686
    618
    638
    648
    668
    688
    811
    831
    841
    861
    881
    813
    833
    843
    863
    883
    814
    834
    844
    864
    884
    816
    836
    846
    866
    886
    818
    838
    848
    868
    888(所影响的行数为 125 行)*/
      

  3.   

    declare @t table(num int)
    insert into @t select 1 union select 3 union select 4 union select 6 union select 8 select
        a.num*100+b.num*10+c.num
    from
        @t a,@t b,@t c
    -----------------
    子陌这方法好。。