某一列.
declare @n nvarchar(4000)
select @n = isnull(@n,'')+col from tb
select @n
某一行,
select ltrim(col1) + ltrim(col2) + ltrim(col3) +...+ ltrim(colN) from tb

解决方案 »

  1.   

    select 列1+列2 from tb
      

  2.   

    --字符串時
    select col=col1+col2........ from tdeclare @s nvarchar(1000)
    set @s=''
    select @s=@s+col1  from t
      

  3.   

    if object_id('tb') is not null
    drop table tb
    go
    --
    CREATE TABLE tb (id int,name varchar(50)) 
    insert into tb select 100,'A1'
    insert into tb select 100,'A2' if object_id('f_hb') is not null
    drop function f_hb
    go
    create function f_hb(@id int)
    returns varchar(8000)
    as
    begin
    declare @re varchar(8000)
    select @re=isnull(@re+'-','')+name from tb where id=@id
    return @re
    end
    go
    select id,dbo.f_hb(id) as name 
    from tb group by idid name
    100 A1-A2
      

  4.   

    05用xml處理
    http://topic.csdn.net/u/20080612/22/c850499f-bce3-4877-82d5-af2357857872.html