不用循环,用循环这就不是问题了。能够直接生能一个指定范围的序列表, 
最好是定义三个变量后,一两条语句就能实现呢。(当然语句中可以嵌入循环)例如
起始:4
步进:2
个数:4
4
6
8
10起始:0
步进:5
个数:4
0
5
10
15

解决方案 »

  1.   

    declare @begin int,@space int,@number intselect @begin = 4,@space = 2,@number = 4select @begin + number*@space
    from master..spt_values
    where type = 'P' and 
    number between 0 and @number - 1
    ----------- 
    4
    6
    8
    10(所影响的行数为 4 行)
      

  2.   

    SELECT 4+2*(NUMBER-1) FROM MASTER..SPT_VALUES WHERE TYPE='P' AND NUMBER BETWEEN 1 AND 4
                
    ----------- 
    4
    6
    8
    10(所影响的行数为 4 行)
      

  3.   


    declare @be int, @step int, @cnt intselect @be=0, @step=5 , @cnt=4select  number
    from master..spt_values
    where type='p'
    and number between @be and  (@cnt-1)*@step +@be
    and  (number-@be)%@step =0/*
    0
    5
    10
    15*/
      

  4.   

    select top 100000 ID=Identity(int,1,1) into #Num from syscolumns a,syscolumns b
      

  5.   

    用循环不好吗?如果不行,可以利用临时表来SELECT ID=IDENTITY(INT,1,1),* INTO #T FROM SYSCOLUMNS ,SYCOLUMNS,SYCOLUMNS