•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 361,552 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,139 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 435 | Replies: 0
![]() |
•
•
Join Date: Apr 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Hi, can anybody shed any light on what I'm doing wrong here...
I'm trying to acheive an XML that looks like the following:
Unfortunately, what I'm actually getting is this:
As you will no doubt notice, all the lengths appear in the 'large' variant when each one is actually associated with the other sizes.
The SQL I'm running is as follows:
ANY HELP WOULD BE MASSIVELY APPRECIATED!
I'm trying to acheive an XML that looks like the following:
<tshirt Name="Stussy NY Posse T-Shirt Yellow">
<variant size="small">
<productID>10</productID>
<dimensions length="34" />
</variant>
<variant size="medium">
<productID>11</productID>
<dimensions length="45" />
</variant>
<variant size="large">
<productID>12</productID>
<dimensions length="50" />
</variant>
</tshirt>Unfortunately, what I'm actually getting is this:
<tshirt Name="Stussy NY Posse T-Shirt Yellow">
<variant size="small">
<productID>10</productID>
</variant>
<variant size="medium">
<productID>11</productID>
</variant>
<variant size="large">
<productID>12</productID>
<dimensions length="34" />
<dimensions length="45" />
<dimensions length="50" />
</variant>
</tshirt>As you will no doubt notice, all the lengths appear in the 'large' variant when each one is actually associated with the other sizes.
The SQL I'm running is as follows:
declare @productid int set @productid = 5 SELECT 1 as Tag, NULL as Parent, pt.Name as [tshirt!1!Name], null as [variant!2!size], null as [variant!2!productID!element], null as [variant!2!dimensions!element], null as [dimensions!3!length] from producttemplates pt where pt.ptid = @productid UNION ALL SELECT 2 as Tag, 1 as Parent, NULL as [tshirt!1!Name], s.Size as [variant!2!size], p.pid as [variant!2!productID!element], null as [variant!2!dimensions!element], null as [dimensions!3!length!element] from sizes s inner join products p on p.sizeid = s.sizeid inner join producttemplates pt on p.ptid = pt.ptid where pt.ptid = @productid union all select 3 as Tag, 2 as Parent, null as [tshirt!1!Name], null as [variant!2!size], null as [variant!2!productID!element], null as [variant!2!dimensions!element], pDim.ShirtLength as [dimensions!3!length!element] from ProductDimensions pDim INNER JOIN products p on p.pid = pDim.pid where p.ptid = @productid for xml explicit
ANY HELP WOULD BE MASSIVELY APPRECIATED!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
- Previous Thread: How to change DB from windows authentication to Server authentication?
- Next Thread: check this error in login


Linear Mode