Convert query to Sqlserver

Asked

Viewed 101 times

2

I have the following query for the Oracle bank:

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

I need to convert to run in the Sqlserver bank, but I’m not getting it. Does anyone know any equivalent function to Sqlserver or other alternative to get the same result.

  • I’ve never seen anything like this in SQL Server, what exactly does this Query ai?

  • I am knowing the query also, apparently it concatenates the data of an xml, coming from the database.

1 answer

0


See if it meets, to get XML data per query in SQL Server:

Example of XML:

 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)')
  • Man, thanks for the help, I can already return the xml values.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.