Search code examples
azuret-sqlazure-synapse

Azure Synapse STUFF with FOR


I am working with a simple query in azure Synapse, however I think the FOR in the following query is not accepted in synapse :

select stuff((select ','+quotename(C.ClaveReferencia)
     from [Landing].[BKPF]  as C
     for xml path('')), 1, 1, '')

Does anybody know a workaround for that?


Solution

  • Answer:

    SELECT ''''+STRING_AGG(CONVERT(NVARCHAR(max), ClaveReferencia), ''',''') AWKEY FROM [Landing].[BKPF]