 |
|
 |
|
Next: viagra suisse commande en ligne viagra soft en li..
|
| Author |
Message |
External

Since: Aug 06, 2008 Posts: 2
|
(Msg. 1) Posted: Mon Aug 04, 2008 6:32 am
Post subject: Shaping this query Archived from groups: microsoft>public>sqlserver>xml (more info?)
|
|
|
Hi,
I'm having a go at an xml query but I'm having problems getting the
correct results with the output xml. Say I have the following flat
table:
Firstname,Surname,Address1,Zip
I want my xml output to be:
<addresses>
<address>
<item key="Firstname" value="John" />
<item key="Surname" value="Smith" />
<item key="Address1" value="The Street" />
<item key="Zip" value="12345" />
</address>
<address>
........
</address>
</addresses.
I'm getting close, but I'm not quite there. Any help appreciated. >> Stay informed about: Shaping this query |
|
| Back to top |
|
 |  |
External

Since: Feb 08, 2005 Posts: 165
|
(Msg. 2) Posted: Mon Aug 04, 2008 12:59 pm
Post subject: RE: Shaping this query [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
I could this to work if there was a unique key in the #addresses table:
DROP TABLE #addresses
GO
CREATE TABLE #addresses ( id INT IDENTITY PRIMARY KEY, Firstname
VARCHAR(50), Surname VARCHAR(50), Address1 VARCHAR(50), Zip VARCHAR(10) )
GO
INSERT INTO #addresses VALUES ( 'John', 'Smith', 'The Street', 12345 )
INSERT INTO #addresses VALUES ( 'Sue', 'Jones', 'The Grove', 34678 )
GO
SELECT
(
SELECT 'Firstname' AS [key], Firstname AS [value]
FROM #addresses item
WHERE a.id = item.id
FOR XML AUTO, TYPE
),
(
SELECT 'Surname' AS [key], Surname AS [value]
FROM #addresses item
WHERE a.id = item.id
FOR XML AUTO, TYPE
),
(
SELECT 'Address1' AS [key], Address1 AS [value]
FROM #addresses item
WHERE a.id = item.id
FOR XML AUTO, TYPE
)
,
(
SELECT 'Zip' AS [key], Zip AS [value]
FROM #addresses item
WHERE a.id = item.id
FOR XML AUTO, TYPE
)
FROM #addresses a
FOR XML RAW( 'address' ), ROOT( 'addresses' )
Dunno if there's an easier way!
HTH
wBob
"spondishy@googlemail.com" wrote:
> Hi,
>
> I'm having a go at an xml query but I'm having problems getting the
> correct results with the output xml. Say I have the following flat
> table:
>
> Firstname,Surname,Address1,Zip
>
> I want my xml output to be:
>
> <addresses>
> <address>
> <item key="Firstname" value="John" />
> <item key="Surname" value="Smith" />
> <item key="Address1" value="The Street" />
> <item key="Zip" value="12345" />
> </address>
> <address>
> ........
> </address>
> </addresses.
>
> I'm getting close, but I'm not quite there. Any help appreciated.
> >> Stay informed about: Shaping this query |
|
| Back to top |
|
 |  |
External

Since: Aug 18, 2008 Posts: 21
|
(Msg. 3) Posted: Mon Aug 18, 2008 8:42 am
Post subject: Re: Shaping this query [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Another Option
DECLARE @t TABLE (FirstName VARCHAR(10), SurName VARCHAR(10), Address
VARCHAR(10), Zip VARCHAR(5))
INSERT INTO @t (FirstName, SurName, Address, Zip)
SELECT 'Jacob', 'Sebastian', '4th street', '38005'
INSERT INTO @t (FirstName, SurName, Address, Zip)
SELECT 'Smith', 'Jones', '9th street', '10002'
SELECT
(SELECT * FROM @t FOR XML RAW('Address'),TYPE)
..query('
for $row in (/Address)
return (
<Address>
<Item Key="FirstName" Value="{$row/@FirstName}"/>
<Item Key="SurName" Value="{$row/@SurName}"/>
<Item Key="Address" Value="{$row/@Address}"/>
<Item Key="Zip" Value="{$row/@Zip}"/>
</Address>
)
')
..query('<Addresses>{/}</Addresses>')
/*
<Addresses>
<Address>
<Item Key="FirstName" Value="Jacob" />
<Item Key="SurName" Value="Sebastian" />
<Item Key="Address" Value="4th street" />
<Item Key="Zip" Value="38005" />
</Address>
<Address>
<Item Key="FirstName" Value="Smith" />
<Item Key="SurName" Value="Jones" />
<Item Key="Address" Value="9th street" />
<Item Key="Zip" Value="10002" />
</Address>
</Addresses>
*/
"Bob" <Bob.TakeThisOut@discussions.microsoft.com> wrote in message
news:75D51784-5FD4-4618-B812-C963046D12F5@microsoft.com...
> I could this to work if there was a unique key in the #addresses table:
>
> DROP TABLE #addresses
> GO
> CREATE TABLE #addresses ( id INT IDENTITY PRIMARY KEY, Firstname
> VARCHAR(50), Surname VARCHAR(50), Address1 VARCHAR(50), Zip VARCHAR(10) )
> GO
>
> INSERT INTO #addresses VALUES ( 'John', 'Smith', 'The Street', 12345 )
> INSERT INTO #addresses VALUES ( 'Sue', 'Jones', 'The Grove', 34678 )
> GO
>
> SELECT
> (
> SELECT 'Firstname' AS [key], Firstname AS [value]
> FROM #addresses item
> WHERE a.id = item.id
> FOR XML AUTO, TYPE
> ),
> (
> SELECT 'Surname' AS [key], Surname AS [value]
> FROM #addresses item
> WHERE a.id = item.id
> FOR XML AUTO, TYPE
> ),
> (
> SELECT 'Address1' AS [key], Address1 AS [value]
> FROM #addresses item
> WHERE a.id = item.id
> FOR XML AUTO, TYPE
> )
> ,
> (
> SELECT 'Zip' AS [key], Zip AS [value]
> FROM #addresses item
> WHERE a.id = item.id
> FOR XML AUTO, TYPE
> )
> FROM #addresses a
> FOR XML RAW( 'address' ), ROOT( 'addresses' )
>
> Dunno if there's an easier way!
> HTH
> wBob
>
> "spondishy@googlemail.com" wrote:
>
>> Hi,
>>
>> I'm having a go at an xml query but I'm having problems getting the
>> correct results with the output xml. Say I have the following flat
>> table:
>>
>> Firstname,Surname,Address1,Zip
>>
>> I want my xml output to be:
>>
>> <addresses>
>> <address>
>> <item key="Firstname" value="John" />
>> <item key="Surname" value="Smith" />
>> <item key="Address1" value="The Street" />
>> <item key="Zip" value="12345" />
>> </address>
>> <address>
>> ........
>> </address>
>> </addresses.
>>
>> I'm getting close, but I'm not quite there. Any help appreciated.
>> >> Stay informed about: Shaping this query |
|
| Back to top |
|
 |  |
External

Since: Feb 08, 2005 Posts: 165
|
(Msg. 4) Posted: Mon Aug 18, 2008 8:42 am
Post subject: Re: Shaping this query [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Nice use of FLOWR statement!
Having checked the execution plans, the first method is much more performant
though, that iteration is costing you big-time!
I suspect there is still an easier way.
"Jacob Sebastian" wrote:
> Another Option
>
> DECLARE @t TABLE (FirstName VARCHAR(10), SurName VARCHAR(10), Address
> VARCHAR(10), Zip VARCHAR(5))
> INSERT INTO @t (FirstName, SurName, Address, Zip)
> SELECT 'Jacob', 'Sebastian', '4th street', '38005'
>
> INSERT INTO @t (FirstName, SurName, Address, Zip)
> SELECT 'Smith', 'Jones', '9th street', '10002'
>
> SELECT
> (SELECT * FROM @t FOR XML RAW('Address'),TYPE)
> ..query('
> for $row in (/Address)
> return (
> <Address>
> <Item Key="FirstName" Value="{$row/@FirstName}"/>
> <Item Key="SurName" Value="{$row/@SurName}"/>
> <Item Key="Address" Value="{$row/@Address}"/>
> <Item Key="Zip" Value="{$row/@Zip}"/>
> </Address>
> )
> ')
> ..query('<Addresses>{/}</Addresses>')
>
> /*
> <Addresses>
> <Address>
> <Item Key="FirstName" Value="Jacob" />
> <Item Key="SurName" Value="Sebastian" />
> <Item Key="Address" Value="4th street" />
> <Item Key="Zip" Value="38005" />
> </Address>
> <Address>
> <Item Key="FirstName" Value="Smith" />
> <Item Key="SurName" Value="Jones" />
> <Item Key="Address" Value="9th street" />
> <Item Key="Zip" Value="10002" />
> </Address>
> </Addresses>
> */
>
>
> "Bob" <Bob.TakeThisOut@discussions.microsoft.com> wrote in message
> news:75D51784-5FD4-4618-B812-C963046D12F5@microsoft.com...
> > I could this to work if there was a unique key in the #addresses table:
> >
> > DROP TABLE #addresses
> > GO
> > CREATE TABLE #addresses ( id INT IDENTITY PRIMARY KEY, Firstname
> > VARCHAR(50), Surname VARCHAR(50), Address1 VARCHAR(50), Zip VARCHAR(10) )
> > GO
> >
> > INSERT INTO #addresses VALUES ( 'John', 'Smith', 'The Street', 12345 )
> > INSERT INTO #addresses VALUES ( 'Sue', 'Jones', 'The Grove', 34678 )
> > GO
> >
> > SELECT
> > (
> > SELECT 'Firstname' AS [key], Firstname AS [value]
> > FROM #addresses item
> > WHERE a.id = item.id
> > FOR XML AUTO, TYPE
> > ),
> > (
> > SELECT 'Surname' AS [key], Surname AS [value]
> > FROM #addresses item
> > WHERE a.id = item.id
> > FOR XML AUTO, TYPE
> > ),
> > (
> > SELECT 'Address1' AS [key], Address1 AS [value]
> > FROM #addresses item
> > WHERE a.id = item.id
> > FOR XML AUTO, TYPE
> > )
> > ,
> > (
> > SELECT 'Zip' AS [key], Zip AS [value]
> > FROM #addresses item
> > WHERE a.id = item.id
> > FOR XML AUTO, TYPE
> > )
> > FROM #addresses a
> > FOR XML RAW( 'address' ), ROOT( 'addresses' )
> >
> > Dunno if there's an easier way!
> > HTH
> > wBob
> >
> > "spondishy@googlemail.com" wrote:
> >
> >> Hi,
> >>
> >> I'm having a go at an xml query but I'm having problems getting the
> >> correct results with the output xml. Say I have the following flat
> >> table:
> >>
> >> Firstname,Surname,Address1,Zip
> >>
> >> I want my xml output to be:
> >>
> >> <addresses>
> >> <address>
> >> <item key="Firstname" value="John" />
> >> <item key="Surname" value="Smith" />
> >> <item key="Address1" value="The Street" />
> >> <item key="Zip" value="12345" />
> >> </address>
> >> <address>
> >> ........
> >> </address>
> >> </addresses.
> >>
> >> I'm getting close, but I'm not quite there. Any help appreciated.
> >>
> >> Stay informed about: Shaping this query |
|
| Back to top |
|
 |  |
External

Since: Aug 18, 2008 Posts: 21
|
(Msg. 5) Posted: Mon Aug 18, 2008 8:08 pm
Post subject: Re: Shaping this query [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Agreed
--
Jacob Sebastian
SQL Server MVP
http://www.sqlserverandxml.com
"Bob" <Bob.DeleteThis@discussions.microsoft.com> wrote in message
news:53779C0F-3923-4044-A788-2134234A34F2@microsoft.com...
> Nice use of FLOWR statement!
>
> Having checked the execution plans, the first method is much more
> performant
> though, that iteration is costing you big-time!
>
> I suspect there is still an easier way.
>
> "Jacob Sebastian" wrote:
>
>> Another Option
>>
>> DECLARE @t TABLE (FirstName VARCHAR(10), SurName VARCHAR(10), Address
>> VARCHAR(10), Zip VARCHAR(5))
>> INSERT INTO @t (FirstName, SurName, Address, Zip)
>> SELECT 'Jacob', 'Sebastian', '4th street', '38005'
>>
>> INSERT INTO @t (FirstName, SurName, Address, Zip)
>> SELECT 'Smith', 'Jones', '9th street', '10002'
>>
>> SELECT
>> (SELECT * FROM @t FOR XML RAW('Address'),TYPE)
>> ..query('
>> for $row in (/Address)
>> return (
>> <Address>
>> <Item Key="FirstName" Value="{$row/@FirstName}"/>
>> <Item Key="SurName" Value="{$row/@SurName}"/>
>> <Item Key="Address" Value="{$row/@Address}"/>
>> <Item Key="Zip" Value="{$row/@Zip}"/>
>> </Address>
>> )
>> ')
>> ..query('<Addresses>{/}</Addresses>')
>>
>> /*
>> <Addresses>
>> <Address>
>> <Item Key="FirstName" Value="Jacob" />
>> <Item Key="SurName" Value="Sebastian" />
>> <Item Key="Address" Value="4th street" />
>> <Item Key="Zip" Value="38005" />
>> </Address>
>> <Address>
>> <Item Key="FirstName" Value="Smith" />
>> <Item Key="SurName" Value="Jones" />
>> <Item Key="Address" Value="9th street" />
>> <Item Key="Zip" Value="10002" />
>> </Address>
>> </Addresses>
>> */
>>
>>
>> "Bob" <Bob.DeleteThis@discussions.microsoft.com> wrote in message
>> news:75D51784-5FD4-4618-B812-C963046D12F5@microsoft.com...
>> > I could this to work if there was a unique key in the #addresses table:
>> >
>> > DROP TABLE #addresses
>> > GO
>> > CREATE TABLE #addresses ( id INT IDENTITY PRIMARY KEY, Firstname
>> > VARCHAR(50), Surname VARCHAR(50), Address1 VARCHAR(50), Zip
>> > VARCHAR(10) )
>> > GO
>> >
>> > INSERT INTO #addresses VALUES ( 'John', 'Smith', 'The Street', 12345 )
>> > INSERT INTO #addresses VALUES ( 'Sue', 'Jones', 'The Grove', 34678 )
>> > GO
>> >
>> > SELECT
>> > (
>> > SELECT 'Firstname' AS [key], Firstname AS [value]
>> > FROM #addresses item
>> > WHERE a.id = item.id
>> > FOR XML AUTO, TYPE
>> > ),
>> > (
>> > SELECT 'Surname' AS [key], Surname AS [value]
>> > FROM #addresses item
>> > WHERE a.id = item.id
>> > FOR XML AUTO, TYPE
>> > ),
>> > (
>> > SELECT 'Address1' AS [key], Address1 AS [value]
>> > FROM #addresses item
>> > WHERE a.id = item.id
>> > FOR XML AUTO, TYPE
>> > )
>> > ,
>> > (
>> > SELECT 'Zip' AS [key], Zip AS [value]
>> > FROM #addresses item
>> > WHERE a.id = item.id
>> > FOR XML AUTO, TYPE
>> > )
>> > FROM #addresses a
>> > FOR XML RAW( 'address' ), ROOT( 'addresses' )
>> >
>> > Dunno if there's an easier way!
>> > HTH
>> > wBob
>> >
>> > "spondishy@googlemail.com" wrote:
>> >
>> >> Hi,
>> >>
>> >> I'm having a go at an xml query but I'm having problems getting the
>> >> correct results with the output xml. Say I have the following flat
>> >> table:
>> >>
>> >> Firstname,Surname,Address1,Zip
>> >>
>> >> I want my xml output to be:
>> >>
>> >> <addresses>
>> >> <address>
>> >> <item key="Firstname" value="John" />
>> >> <item key="Surname" value="Smith" />
>> >> <item key="Address1" value="The Street" />
>> >> <item key="Zip" value="12345" />
>> >> </address>
>> >> <address>
>> >> ........
>> >> </address>
>> >> </addresses.
>> >>
>> >> I'm getting close, but I'm not quite there. Any help appreciated.
>> >>
>> >> Stay informed about: Shaping this query |
|
| Back to top |
|
 |  |
External

Since: Aug 18, 2008 Posts: 21
|
(Msg. 6) Posted: Mon Aug 18, 2008 11:13 pm
Post subject: Re: Shaping this query [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Hi Bob,
could you contact me off the list?
my email is jacob[dot]reliancesp[at]gmail[dot]com
thanks
Jacob
--
Jacob Sebastian
SQL Server MVP
http://www.sqlserverandxml.com
"Bob" <Bob.RemoveThis@discussions.microsoft.com> wrote in message
news:53779C0F-3923-4044-A788-2134234A34F2@microsoft.com...
> Nice use of FLOWR statement!
>
> Having checked the execution plans, the first method is much more
> performant
> though, that iteration is costing you big-time!
>
> I suspect there is still an easier way.
>
> "Jacob Sebastian" wrote:
>
>> Another Option
>>
>> DECLARE @t TABLE (FirstName VARCHAR(10), SurName VARCHAR(10), Address
>> VARCHAR(10), Zip VARCHAR(5))
>> INSERT INTO @t (FirstName, SurName, Address, Zip)
>> SELECT 'Jacob', 'Sebastian', '4th street', '38005'
>>
>> INSERT INTO @t (FirstName, SurName, Address, Zip)
>> SELECT 'Smith', 'Jones', '9th street', '10002'
>>
>> SELECT
>> (SELECT * FROM @t FOR XML RAW('Address'),TYPE)
>> ..query('
>> for $row in (/Address)
>> return (
>> <Address>
>> <Item Key="FirstName" Value="{$row/@FirstName}"/>
>> <Item Key="SurName" Value="{$row/@SurName}"/>
>> <Item Key="Address" Value="{$row/@Address}"/>
>> <Item Key="Zip" Value="{$row/@Zip}"/>
>> </Address>
>> )
>> ')
>> ..query('<Addresses>{/}</Addresses>')
>>
>> /*
>> <Addresses>
>> <Address>
>> <Item Key="FirstName" Value="Jacob" />
>> <Item Key="SurName" Value="Sebastian" />
>> <Item Key="Address" Value="4th street" />
>> <Item Key="Zip" Value="38005" />
>> </Address>
>> <Address>
>> <Item Key="FirstName" Value="Smith" />
>> <Item Key="SurName" Value="Jones" />
>> <Item Key="Address" Value="9th street" />
>> <Item Key="Zip" Value="10002" />
>> </Address>
>> </Addresses>
>> */
>>
>>
>> "Bob" <Bob.RemoveThis@discussions.microsoft.com> wrote in message
>> news:75D51784-5FD4-4618-B812-C963046D12F5@microsoft.com...
>> > I could this to work if there was a unique key in the #addresses table:
>> >
>> > DROP TABLE #addresses
>> > GO
>> > CREATE TABLE #addresses ( id INT IDENTITY PRIMARY KEY, Firstname
>> > VARCHAR(50), Surname VARCHAR(50), Address1 VARCHAR(50), Zip
>> > VARCHAR(10) )
>> > GO
>> >
>> > INSERT INTO #addresses VALUES ( 'John', 'Smith', 'The Street', 12345 )
>> > INSERT INTO #addresses VALUES ( 'Sue', 'Jones', 'The Grove', 34678 )
>> > GO
>> >
>> > SELECT
>> > (
>> > SELECT 'Firstname' AS [key], Firstname AS [value]
>> > FROM #addresses item
>> > WHERE a.id = item.id
>> > FOR XML AUTO, TYPE
>> > ),
>> > (
>> > SELECT 'Surname' AS [key], Surname AS [value]
>> > FROM #addresses item
>> > WHERE a.id = item.id
>> > FOR XML AUTO, TYPE
>> > ),
>> > (
>> > SELECT 'Address1' AS [key], Address1 AS [value]
>> > FROM #addresses item
>> > WHERE a.id = item.id
>> > FOR XML AUTO, TYPE
>> > )
>> > ,
>> > (
>> > SELECT 'Zip' AS [key], Zip AS [value]
>> > FROM #addresses item
>> > WHERE a.id = item.id
>> > FOR XML AUTO, TYPE
>> > )
>> > FROM #addresses a
>> > FOR XML RAW( 'address' ), ROOT( 'addresses' )
>> >
>> > Dunno if there's an easier way!
>> > HTH
>> > wBob
>> >
>> > "spondishy@googlemail.com" wrote:
>> >
>> >> Hi,
>> >>
>> >> I'm having a go at an xml query but I'm having problems getting the
>> >> correct results with the output xml. Say I have the following flat
>> >> table:
>> >>
>> >> Firstname,Surname,Address1,Zip
>> >>
>> >> I want my xml output to be:
>> >>
>> >> <addresses>
>> >> <address>
>> >> <item key="Firstname" value="John" />
>> >> <item key="Surname" value="Smith" />
>> >> <item key="Address1" value="The Street" />
>> >> <item key="Zip" value="12345" />
>> >> </address>
>> >> <address>
>> >> ........
>> >> </address>
>> >> </addresses.
>> >>
>> >> I'm getting close, but I'm not quite there. Any help appreciated.
>> >>
>> >> Stay informed about: Shaping this query |
|
| Back to top |
|
 |  |
External

Since: Feb 08, 2005 Posts: 165
|
(Msg. 7) Posted: Wed Aug 20, 2008 9:37 am
Post subject: RE: Shaping this query [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Had another think about this, and this works really well, winning the battle
of the execution plans too:
CREATE TABLE #addresses ( id INT IDENTITY PRIMARY KEY, Firstname
VARCHAR(50), Surname VARCHAR(50), Address1 VARCHAR(50), Zip VARCHAR(10) )
GO
INSERT INTO #addresses VALUES ( 'John', 'Smith', 'The Street', 12345 )
INSERT INTO #addresses VALUES ( 'Sue', 'Jones', 'The Grove', 34678 )
GO
SELECT CAST( '<item key="Firstname" value="' + Firstname + '" />
<item key="Surname" value="' + Surname + '" />
<item key="Address1" value="' + Address1 + '" />
<item key="Zip" value="' + Zip + '" />' AS XML )
FROM #addresses
FOR XML RAW( 'address' ), ROOT( 'addresses' ), TYPE
"spondishy@googlemail.com" wrote:
> Hi,
>
> I'm having a go at an xml query but I'm having problems getting the
> correct results with the output xml. Say I have the following flat
> table:
>
> Firstname,Surname,Address1,Zip
>
> I want my xml output to be:
>
> <addresses>
> <address>
> <item key="Firstname" value="John" />
> <item key="Surname" value="Smith" />
> <item key="Address1" value="The Street" />
> <item key="Zip" value="12345" />
> </address>
> <address>
> ........
> </address>
> </addresses.
>
> I'm getting close, but I'm not quite there. Any help appreciated.
> >> Stay informed about: Shaping this query |
|
| Back to top |
|
 |  |
External

Since: Aug 18, 2008 Posts: 21
|
(Msg. 8) Posted: Thu Aug 21, 2008 7:59 pm
Post subject: Re: Shaping this query [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
nice idea Bob.
the only downside I can think of is about having special characters in the
attribute value. For example, if the name contains a double quotes or
less-than sign, this will not work.
But I don’t think such cases will be rare.
--
Jacob Sebastian
SQL Server MVP
http://www.sqlserverandxml.com
"Bob" <Bob.RemoveThis@discussions.microsoft.com> wrote in message
news:D3D4A98A-A2BB-4F38-ADD4-EF5D104813B6@microsoft.com...
> Had another think about this, and this works really well, winning the
> battle
> of the execution plans too:
>
> CREATE TABLE #addresses ( id INT IDENTITY PRIMARY KEY, Firstname
> VARCHAR(50), Surname VARCHAR(50), Address1 VARCHAR(50), Zip VARCHAR(10) )
> GO
>
> INSERT INTO #addresses VALUES ( 'John', 'Smith', 'The Street', 12345 )
> INSERT INTO #addresses VALUES ( 'Sue', 'Jones', 'The Grove', 34678 )
> GO
>
> SELECT CAST( '<item key="Firstname" value="' + Firstname + '" />
> <item key="Surname" value="' + Surname + '" />
> <item key="Address1" value="' + Address1 + '" />
> <item key="Zip" value="' + Zip + '" />' AS XML )
> FROM #addresses
> FOR XML RAW( 'address' ), ROOT( 'addresses' ), TYPE
>
>
>
> "spondishy@googlemail.com" wrote:
>
>> Hi,
>>
>> I'm having a go at an xml query but I'm having problems getting the
>> correct results with the output xml. Say I have the following flat
>> table:
>>
>> Firstname,Surname,Address1,Zip
>>
>> I want my xml output to be:
>>
>> <addresses>
>> <address>
>> <item key="Firstname" value="John" />
>> <item key="Surname" value="Smith" />
>> <item key="Address1" value="The Street" />
>> <item key="Zip" value="12345" />
>> </address>
>> <address>
>> ........
>> </address>
>> </addresses.
>>
>> I'm getting close, but I'm not quite there. Any help appreciated.
>> >> Stay informed about: Shaping this query |
|
| Back to top |
|
 |  |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|