|
|
|
date: Mon, 9 Jun 2008 05:55:41 -0700,
group: microsoft.public.sqlserver.xml
back
Re: Create XML, first line
Try putting the FOR XML EXPLICIT in a subquery (***untested***):
DECLARE @v VARCHAR(MAX);
SET @v = '<?xml version="1.0" encoding="UTF-8"?>' +
(
select 1 as TAG, NULL as Parent, xx as [variable!1!name], yy as
[variable!1!!element] FROM zz for XML EXPLICIT, ROOT('test')
);
Obviously won't work if you're using SQL 2000.
========
Michael Coles
"Pro SQL Server 2008 XML"
http://www.amazon.com/Pro-SQL-Server-2008-XML/dp/1590599837/
"Anders" wrote in message
news:F687A896-0D9E-49C8-B04F-516055D762D5@microsoft.com...
> How do I add <?xml version="1.0" encoding="UTF-8"?> to the first line of
> the
> output from this query?
>
> select 1 as TAG, NULL as Parent, xx as [variable!1!name], yy as
> [variable!1!!element] FROM zz for XML EXPLICIT, ROOT('test')
>
> Thanks!
>
date: Sat, 14 Jun 2008 17:28:31 -0400
author: Michael Coles michaelcoREPLACE_THIS_WITH_AT_SIGNoptonline.net
Re: Create XML, first line
Try something like this (***untested***):
DECLARE @v varchar(max);
SET @v = '<?xml version="1.0" encoding="UTF-8"?>' +
(
select 1 as TAG, NULL as Parent, xx as [variable!1!name], yy as
[variable!1!!element] FROM zz for XML EXPLICIT, ROOT('test')
);
Obviously won't work on SQL 2000.
--
========
Michael Coles
"Pro SQL Server 2008 XML"
http://www.amazon.com/Pro-SQL-Server-2008-XML/dp/1590599837/
"Anders" wrote in message
news:F687A896-0D9E-49C8-B04F-516055D762D5@microsoft.com...
> How do I add <?xml version="1.0" encoding="UTF-8"?> to the first line of
> the
> output from this query?
>
> select 1 as TAG, NULL as Parent, xx as [variable!1!name], yy as
> [variable!1!!element] FROM zz for XML EXPLICIT, ROOT('test')
>
> Thanks!
>
date: Sat, 14 Jun 2008 17:32:38 -0400
author: Michael Coles michaelcoREPLACE_THIS_WITH_AT_SIGNoptonline.net
|
|