I
I
Ilya2019-05-20 15:47:21
SQL Server
Ilya, 2019-05-20 15:47:21

How to write the generated xml document to a string?

I generated an xml document using the for xml function, where can I save the result? When trying to add insert into / select into to the query or assigning the result to a variable, it says that these constructs cannot be used with for xml. How to proceed then?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VMesser, 2019-05-26
@illaaa

Declare @xml as xml
, @str as nvarchar(max)
select @xml = (select ... for xml)
select @str = cast(@xml as nvarxhar(max))

K
Konstantin Tsvetkov, 2019-05-20
@tsklab

Data Type Conversion .

What into what:
lrdatahd.png?view=sql-server-2017

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question