Convert query to SQLServer

1

I have the following query for the Oracle database:

select xmlagg(xmlelement(e, d.delinha, '').extract('//text()') order by d.nulinha).getclobval() .

I need to convert to run on SQLServer database, but I can not. Does anyone know of a function equivalent to SQLServer or another alternative to get the same result.

    
asked by anonymous 10.11.2017 / 12:56

1 answer

0

See if, to get data from one XML per query in SQL Server:

XML example:

 DECLARE @myDoc xml 

SET @myDoc = '<log expressao="7085">
<par traduzir="N">André Mariano da Silva</par>
<par traduzir="N">Gestores Boavista</par>
<par formatarData="S">
<par traduzir="N">21/09/2017 09:19:00</par>
</par>
<par traduzir="N">Teste</par>
</log>'  

select  @myDoc.query('(/log/par/par)')

If you want to return only the value, use the value () function

SELECT  @myDoc.value('(/log/par/par)[1]', 'varchar(30)')
    
10.11.2017 / 13:49