Hello
I have stored procedure returning XML. XML returned not as parameter but as result of SELECT:
create procedure #xml_test
as
select 1 as a for xml raw
go
I'm trying to put this XML in a variable:
declare @xml as nvarchar(max)
But I can't find how to do it. My best idea was INSERT INTO ... EXEC, but I get error 'The FOR XML clause is not allowed in a INSERT statement.':
create table #tmp(col1 nvarchar(max) not null)
insert into #tmp
exec #xml_test
This approach works well for usual text:
create procedure #text_test
as
select 'aaa' as a
go
insert into #tmp
exec #text_test
I wonder if somebody bumped into this issue before? I'm on SQL Server 2005