Sqlserver
 sql >> Base de Dados >  >> RDS >> Sqlserver

Junte caracteres usando SET BASED APPROACH (Sql Server 2005)


Só precisa acertar o bit XML PATH ...
CREATE TABLE #foo (bar char(1))

INSERT #foo SELECT 'a' UNION ALL SELECT 'b' UNION ALL SELECT 'c'
GO

SELECT
    buzz
FROM
    (
    SELECT 
        CAST(bar AS varchar(8000))
    FROM 
        #foo
    FOR XML PATH ('')
    ) fizz(buzz)

DROP TABLE #foo