April 4, 2008 at 7:02 am
can somebody help me. i have this simple record.
error_reference_uid item_number error_code
1234567 13579 odd
1234567 2468 even
and i want to create this xml.
i tried this
SELECT item_number, error_code, Qty FROM xml_file_item_errors FOR XML AUTO, TYPE
and gave me this result.
please help.
April 11, 2008 at 10:43 am
Wow.
I really wish that the {code} IFcode tags would treat their contents as literals and not strip out the html & xml tags.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
April 15, 2008 at 4:59 am
rbarryyoung (4/11/2008)
Wow.I really wish that the {code} IFcode tags would treat their contents as literals and not strip out the html & xml tags.
Agreed. The trick is to replace all instances of < with <
And it's not easy to tell you that either! 😀
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 16, 2008 at 9:34 am
I feel bad for the OP, but we can't really do much for them until they can post something that we can see. Maybe an attachment?
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
April 16, 2008 at 9:46 am
rbarryyoung (4/16/2008)
I feel bad for the OP, but we can't really do much for them until they can post something that we can see. Maybe an attachment?
I've just searched and found that the OP also posted the question here...
http://forums.devx.com/showthread.php?t=167320
So now we have something to work with 🙂
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 17, 2008 at 3:39 am
How's this?
--Data
declare @Sample table (error_reference_uid int, item_number int, error_code varchar(10))
insert @Sample
select 1234567, 13579, 'odd'
union all select 1234567, 2468, 'even'
union all select 1111, 2222, 'abcd'
--Inputs
declare @error_reference_uid int
set @error_reference_uid = 1234567
--Calculation
select
@error_reference_uid as '@error_reference_uid',
(select
item_number as '@item_number',
error_code as '@error_code'
from @Sample where error_reference_uid = @error_reference_uid for xml path('Error'), type)
FOR XML PATH ('Errors')
/* Results
<Errors error_reference_uid="1234567">
<Error item_number="13579" error_code="odd" />
<Error item_number="2468" error_code="even" />
</Errors>
*/
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply