Using SQL Server 2008, I have a query that emits a result set using FOR XML. Right now it is a non-compliant fragment.
How can I wrap my result XML in an enclosing e
It is not possible to have the xml processing instruction in a xml datatype in sql server. See Limitations of the xml Data Type
This code
declare @XML xml =
'
Value '
select @XML
Has the output
Value
You can build the xml as a string with the xml processing instruction in place.
declare @XML xml = 'Value '
declare @XMLStr nvarchar(max) = ''
set @XMLStr = @XMLStr + cast(@XML as nvarchar(max))
select @XMLStr
Output
--------------------------------------------------------------------------
Value