sql sever 里边 比如 
ID  NAME
1   张三显示成:   ID    1
           NAME  张三怎么弄 ,给为高手帮帮忙

解决方案 »

  1.   

    给你一个存储过程万用的 SQLcenter写的
    http://topic.csdn.net/u/20101026/22/e20a367d-bcb2-4ba2-b2c3-f7503df9c928.html?66483
      

  2.   

    你好,   
       2楼的说的好。   其实行列转换。csdn你只要一搜,就会有好多。   
       如果搜不到的。   不了解的。  相信会有很多大虾来答的。   大多都不想答了。  不是分的原因。而是你要学会找答案。   
      

  3.   

    --行列互换/*--有表
    indust     200301     200302     200303     
    ---------- ---------- ---------- ---------- 
    a          111        222        333
    b          444        555        666
    c          777        888        999
    d          789        910        012
    --要求得到结果
    日期     a    b    c    d    
    ------ ---- ---- ---- ---- 
    200301 111  444  777  789
    200302 222  555  888  910
    200303 333  666  999  012
    --*/--创建测试表
    create table test(indust varchar(10)
    ,[200301] varchar(10)
    ,[200302] varchar(10)
    ,[200303] varchar(10))
    insert test select 'a','111','222','333'
    union all select 'b','444','555','666' 
    union all select 'c','777','888','999'
    union all select 'd','789','910','012'
    go--数据处理
    declare @f1 varchar(8000),@f2 varchar(8000),@f3 varchar(8000)
    select @f1='',@f2='',@f3=''
    select @f1=@f1+',['+indust+']='''+[200301]+''''
    ,@f2=@f2+','''+[200302]+''''
    ,@f3=@f3+','''+[200303]+''''
    from test
    exec('select 日期=''200301'''+@f1
    +' union all select ''200302'''+@f2
    +' union all select ''200303'''+@f3)
    go
    --删除测试表
    select * from test
    drop table test/*--测试结果
    日期     a    b    c    d    
    ------ ---- ---- ---- ---- 
    200301 111  444  777  789
    200302 222  555  888  910
    200303 333  666  999  012
    --*/版权归邹老大所有