Convert the result of dynamic sql to xml

7331

New Member
I want to execute the following T-sql\[code\]declare @sql varchar(max) = 'select 1 a, 2 b for xml path (''''), root(''root'')'declare @t table (x xml)insert into @t exec (@sql)\[/code\]However, I got the error message of \[quote\] Msg 6819, Level 16, State 5, Line 2 The FOR XML clause is not allowed in a INSERT statement\[/quote\]
 
Back
Top