例如有一列值为(1,2,3,4)中的某个值
想得到数据列表的格式为
第一条数据列值为1   第二条数据列值为2   第三条数据列值为3   第四条数据列值为4
第五条数据列值为1   第六条数据列值为2   第七条数据列值为3   第八条数据列值为4
..............以此类推

解决方案 »

  1.   

    select
      col1=parname(replace(col,',','.'),4),
      col2=parname(replace(col,',','.'),3),
      col3=parname(replace(col,',','.'),2),
      col4=parname(replace(col,',','.'),1)
    from
      tb
      

  2.   

    楼主是要构建1,2,3,4的无限循环是吧.select 
    case when (number-1)%4=0 then 1
    when (number-2)%4=0 then 2
    when (number-3)%4=0 then 3
    when (number-4)%4=0 then 4 end x
    from master..spt_values
    where type='P' and number>0x
    -----------
    1
    2
    3
    4
    1
    2
    3
    4
    1
    2
    3
    4
    .
    .
    .
      

  3.   


    create table tab1(id int) -- 原始表
    create table tab2(id int) -- 目标表insert into tab1 
    select 1 union all
    select 2 union all
    select 3 union all
    select 4 union all
    select 5insert into tab2(id) select id from tab1
    go 3  -- 循环3次1-5.select * from tab2id
    -----------
    1
    2
    3
    4
    5
    1
    2
    3
    4
    5
    1
    2
    3
    4
    5
    (15 row(s) affected)