本帖最后由 higoku 于 2012-02-14 15:44:57 编辑

解决方案 »

  1.   

    好像用函数可以解决,或者用存储过程.
    这个是比较特殊的聚合函数,可以用.net写一个聚合函数.
    微软的哪个自定义聚合函数部分的实例就是用连接字符串的函数
      

  2.   

    declare @id varchar(100)
    declare @fepo varchar(max)
    declare cc cursor for select distinct Id from table1declare @table table(FEPO varchar(max) ,ID varchar(100))open cc
    while 2>1
    begin
    fetch next from cc into @Id
    if @@fetch_status<>0 break
    select @fepo=''
    select @fepo=@fepo+fepo+',' from table1 where id=@id
    insert into @table (fepo,id)
    select left(@fepo,len(@fepo)-1),@id
    end
    deallocate cc
    select * from @table
      

  3.   


    不是这样子的,不好意思啊,你理解错了,ID是主表的ID,FEPO是从表的FEPO,意思是说主表可以有多个对应的从表信息,而且从表查出来的那一列要显示在一行里面.