create view v_s
as
select f_xm,f_bm,c1 as c from webkqdj
union all
select f_xm,f_bm,c2 as c from webkqdj
union all
select f_xm,f_bm,c3 as c from webkqdj
union all
select f_xm,f_bm,c4 as c from webkqdj
union all
select f_xm,f_bm,c5 as c from webkqdj
union all
select f_xm,f_bm,c6 as c from webkqdj
union all
select f_xm,f_bm,c7 as c from webkqdj
union all
select f_xm,f_bm,c8 as c from webkqdj
union all
select f_xm,f_bm,c9 as c from webkqdj
union all
select f_xm,f_bm,c10 as c from webkqdj
union all
select f_xm,f_bm,c11 as c from webkqdj
union all
select f_xm,f_bm,c12 as c from webkqdj
union all
select f_xm,f_bm,c13 as c from webkqdj
union all
select f_xm,f_bm,c14 as c from webkqdj
union all
select f_xm,f_bm,c15 as c from webkqdj
union all
select f_xm,f_bm,c16 as c from webkqdj
union all
select f_xm,f_bm,c17 as c from webkqdj
union all
select f_xm,f_bm,c18 as c from webkqdj
union all
select f_xm,f_bm,c19 as c from webkqdj
union all
select f_xm,f_bm,c20 as c from webkqdj
union all
select f_xm,f_bm,c21 as c from webkqdj
union all
select f_xm,f_bm,c22 as c from webkqdj
union all
select f_xm,f_bm,c23 as c from webkqdj
union all
select f_xm,f_bm,c24 as c from webkqdj
union all
select f_xm,f_bm,c25 as c from webkqdj
union all
select f_xm,f_bm,c26 as c from webkqdj
union all
select f_xm,f_bm,c27 as c from webkqdj
union all
select f_xm,f_bm,c28 as c from webkqdj
union all
select f_xm,f_bm,c29 as c from webkqdj
union all
select f_xm,f_bm,c30 as c from webkqdj
union all
select f_xm,f_bm,c31 as c from webkqdjgo各位大侠,帮帮忙

解决方案 »

  1.   

    create table T(f_xm,f_bm,c) ---字段类型你自己定义一下。insert into T
    select f_xm,f_bm,c1 as c from webkqdj insert into T
    select f_xm,f_bm,c2 as c from webkqdj 
    ...................一次c3c31//应用 T
    //删除T
      

  2.   

    临时表?
    select * into # from ( 
    select f_xm,f_bm,c1 as c from webkqdj 
    union all 
    select f_xm,f_bm,c2 as c from webkqdj 
    union all 
    select f_xm,f_bm,c3 as c from webkqdj 
    union all 
    select f_xm,f_bm,c4 as c from webkqdj 
    union all 
    select f_xm,f_bm,c5 as c from webkqdj 
    union all 
    select f_xm,f_bm,c6 as c from webkqdj 
    union all 
    select f_xm,f_bm,c7 as c from webkqdj 
    union all 
    select f_xm,f_bm,c8 as c from webkqdj 
    union all 
    select f_xm,f_bm,c9 as c from webkqdj 
    union all 
    select f_xm,f_bm,c10 as c from webkqdj 
    union all 
    select f_xm,f_bm,c11 as c from webkqdj 
    union all 
    select f_xm,f_bm,c12 as c from webkqdj 
    union all 
    select f_xm,f_bm,c13 as c from webkqdj 
    union all 
    select f_xm,f_bm,c14 as c from webkqdj 
    union all 
    select f_xm,f_bm,c15 as c from webkqdj 
    union all 
    select f_xm,f_bm,c16 as c from webkqdj 
    union all 
    select f_xm,f_bm,c17 as c from webkqdj 
    union all 
    select f_xm,f_bm,c18 as c from webkqdj 
    union all 
    select f_xm,f_bm,c19 as c from webkqdj 
    union all 
    select f_xm,f_bm,c20 as c from webkqdj 
    union all 
    select f_xm,f_bm,c21 as c from webkqdj 
    union all 
    select f_xm,f_bm,c22 as c from webkqdj 
    union all 
    select f_xm,f_bm,c23 as c from webkqdj 
    union all 
    select f_xm,f_bm,c24 as c from webkqdj 
    union all 
    select f_xm,f_bm,c25 as c from webkqdj 
    union all 
    select f_xm,f_bm,c26 as c from webkqdj 
    union all 
    select f_xm,f_bm,c27 as c from webkqdj 
    union all 
    select f_xm,f_bm,c28 as c from webkqdj 
    union all 
    select f_xm,f_bm,c29 as c from webkqdj 
    union all 
    select f_xm,f_bm,c30 as c from webkqdj 
    union all 
    select f_xm,f_bm,c31 as c from webkqdj ) t
      

  3.   

    select * into #tb from
    (
    select f_xm,f_bm,c1 as c from webkqdj 
    union all 
    select f_xm,f_bm,c2 as c from webkqdj 
    union all 
    select f_xm,f_bm,c3 as c from webkqdj 
    union all 
    select f_xm,f_bm,c4 as c from webkqdj 
    union all 
    select f_xm,f_bm,c5 as c from webkqdj 
    union all 
    select f_xm,f_bm,c6 as c from webkqdj 
    union all 
    select f_xm,f_bm,c7 as c from webkqdj 
    union all 
    select f_xm,f_bm,c8 as c from webkqdj 
    union all 
    select f_xm,f_bm,c9 as c from webkqdj 
    union all 
    select f_xm,f_bm,c10 as c from webkqdj 
    union all 
    select f_xm,f_bm,c11 as c from webkqdj 
    union all 
    select f_xm,f_bm,c12 as c from webkqdj 
    union all 
    select f_xm,f_bm,c13 as c from webkqdj 
    union all 
    select f_xm,f_bm,c14 as c from webkqdj 
    union all 
    select f_xm,f_bm,c15 as c from webkqdj 
    union all 
    select f_xm,f_bm,c16 as c from webkqdj 
    union all 
    select f_xm,f_bm,c17 as c from webkqdj 
    union all 
    select f_xm,f_bm,c18 as c from webkqdj 
    union all 
    select f_xm,f_bm,c19 as c from webkqdj 
    union all 
    select f_xm,f_bm,c20 as c from webkqdj 
    union all 
    select f_xm,f_bm,c21 as c from webkqdj 
    union all 
    select f_xm,f_bm,c22 as c from webkqdj 
    union all 
    select f_xm,f_bm,c23 as c from webkqdj 
    union all 
    select f_xm,f_bm,c24 as c from webkqdj 
    union all 
    select f_xm,f_bm,c25 as c from webkqdj 
    union all 
    select f_xm,f_bm,c26 as c from webkqdj 
    union all 
    select f_xm,f_bm,c27 as c from webkqdj 
    union all 
    select f_xm,f_bm,c28 as c from webkqdj 
    union all 
    select f_xm,f_bm,c29 as c from webkqdj 
    union all 
    select f_xm,f_bm,c30 as c from webkqdj 
    union all 
    select f_xm,f_bm,c31 as c from webkqdj 
    ) T
      

  4.   

    SELECT * INTO 表名 FROM (
    select f_xm,f_bm,c1 as c from webkqdj 
    union all 
    select f_xm,f_bm,c2 as c from webkqdj 
    union all 
    select f_xm,f_bm,c3 as c from webkqdj 
    union all 
    select f_xm,f_bm,c4 as c from webkqdj 
    union all 
    select f_xm,f_bm,c5 as c from webkqdj 
    union all 
    select f_xm,f_bm,c6 as c from webkqdj 
    union all 
    select f_xm,f_bm,c7 as c from webkqdj 
    union all 
    select f_xm,f_bm,c8 as c from webkqdj 
    union all 
    select f_xm,f_bm,c9 as c from webkqdj 
    union all 
    select f_xm,f_bm,c10 as c from webkqdj 
    union all 
    select f_xm,f_bm,c11 as c from webkqdj 
    union all 
    select f_xm,f_bm,c12 as c from webkqdj 
    union all 
    select f_xm,f_bm,c13 as c from webkqdj 
    union all 
    select f_xm,f_bm,c14 as c from webkqdj 
    union all 
    select f_xm,f_bm,c15 as c from webkqdj 
    union all 
    select f_xm,f_bm,c16 as c from webkqdj 
    union all 
    select f_xm,f_bm,c17 as c from webkqdj 
    union all 
    select f_xm,f_bm,c18 as c from webkqdj 
    union all 
    select f_xm,f_bm,c19 as c from webkqdj 
    union all 
    select f_xm,f_bm,c20 as c from webkqdj 
    union all 
    select f_xm,f_bm,c21 as c from webkqdj 
    union all 
    select f_xm,f_bm,c22 as c from webkqdj 
    union all 
    select f_xm,f_bm,c23 as c from webkqdj 
    union all 
    select f_xm,f_bm,c24 as c from webkqdj 
    union all 
    select f_xm,f_bm,c25 as c from webkqdj 
    union all 
    select f_xm,f_bm,c26 as c from webkqdj 
    union all 
    select f_xm,f_bm,c27 as c from webkqdj 
    union all 
    select f_xm,f_bm,c28 as c from webkqdj 
    union all 
    select f_xm,f_bm,c29 as c from webkqdj 
    union all 
    select f_xm,f_bm,c30 as c from webkqdj 
    union all 
    select f_xm,f_bm,c31 as c from webkqdj 
    )T
    go 
      

  5.   

    --如果臨時表基與視圖
    SELECT * INTO # FROM view v_s
      

  6.   

    动态SQL实现创建视图的示例:
    declare @sql varchar(8000)
    set @sql=''select 
        @sql=@sql+' union all select f_xm,f_bm,'+name+' as c from webkqdj '
    from
        syscolumns
    where
        id=object_id('webkqdj')
        and
        name like 'c%'set @sql='create view v_s as '+ stuff(@sql,1,11,'')exec(@sql)
      

  7.   

    select f_xm,f_bm,c1 as c into # --臨時表
     from webkqdj
    union all
    select f_xm,f_bm,c2 as c from webkqdj
    union all
    select f_xm,f_bm,c3 as c from webkqdj
    union all
    select f_xm,f_bm,c4 as c from webkqdj
    union all
    select f_xm,f_bm,c5 as c from webkqdj
    union all
    select f_xm,f_bm,c6 as c from webkqdj
    union all
    select f_xm,f_bm,c7 as c from webkqdj
    union all
    select f_xm,f_bm,c8 as c from webkqdj
    union all
    select f_xm,f_bm,c9 as c from webkqdj
    union all
    select f_xm,f_bm,c10 as c from webkqdj
    union all
    select f_xm,f_bm,c11 as c from webkqdj
    union all
    select f_xm,f_bm,c12 as c from webkqdj
    union all
    select f_xm,f_bm,c13 as c from webkqdj
    union all
    select f_xm,f_bm,c14 as c from webkqdj
    union all
    select f_xm,f_bm,c15 as c from webkqdj
    union all
    select f_xm,f_bm,c16 as c from webkqdj
    union all
    select f_xm,f_bm,c17 as c from webkqdj
    union all
    select f_xm,f_bm,c18 as c from webkqdj
    union all
    select f_xm,f_bm,c19 as c from webkqdj
    union all
    select f_xm,f_bm,c20 as c from webkqdj
    union all
    select f_xm,f_bm,c21 as c from webkqdj
    union all
    select f_xm,f_bm,c22 as c from webkqdj
    union all
    select f_xm,f_bm,c23 as c from webkqdj
    union all
    select f_xm,f_bm,c24 as c from webkqdj
    union all
    select f_xm,f_bm,c25 as c from webkqdj
    union all
    select f_xm,f_bm,c26 as c from webkqdj
    union all
    select f_xm,f_bm,c27 as c from webkqdj
    union all
    select f_xm,f_bm,c28 as c from webkqdj
    union all
    select f_xm,f_bm,c29 as c from webkqdj
    union all
    select f_xm,f_bm,c30 as c from webkqdj
    union all
    select f_xm,f_bm,c31 as c from webkqdj 
      

  8.   

    太牛了,没别话说了CSDN太感了人,朋友们太热心了