就是说如果我执行某个select语句,找到两条数据,内容分别为
A
B而我要返回的值是 AB
这样的函数或语句要怎么写,帮帮忙啊,谢谢!

解决方案 »

  1.   

    declare @s varchar(8000)
    set @s=''select @s=@s+col from tb where 条件print @s
      

  2.   

    create table #t(f1 varchar(100))insert into #t select 'A'
    insert into #t select 'B'declare @s varchar(8000)set @s=''select @s=@s+f1 from #tselect @sdrop table #t
      

  3.   

    declare @t table (a varchar(10))
    insert into @t 
    select 'a' union all 
    select 'b'decalre @str varchar(8000)
    set @str =''
    select @str = @str + rtrim(a) from @t 
    select @str