मेरे पास यह तालिका संरचना है। YearPart, MonthPart और DatePart शामिल है कि वे क्या वर्णन ... पूर्व: 2011, 1, 19 (क्रमशः)एसक्यूएल "एक्सएमएल पथ के लिए" - नेस्टेड परिणाम
DECLARE @agenda AS TABLE (
PID INT IDENTITY(1,1) PRIMARY KEY,
YearPart int,
MonthPart int,
DayPart int,
lib_title nvarchar(200),
[filename] nvarchar(255),
meta_value nvarchar(2000)
)
इस नमूना डेटा का उपयोग करना:
INSERT INTO @agenda VALUES (2010, 12, 4, 'Test Record', '', '')
INSERT INTO @agenda VALUES (2011, 1, 3, 'Another Record', '', '')
INSERT INTO @agenda VALUES (2011, 1, 3, 'Fred Birthday', '', '')
INSERT INTO @agenda VALUES (2011, 1, 4, 'Work Day', '', '')
INSERT INTO @agenda VALUES (2011, 12, 6, '2nd Test Record', '', '')
क्या मैं चाहता हूँ, जैसे एक एक्सएमएल उत्पादन होता है इस:
<root>
<Year Year="2010">
<Month Month="12">
<Day Day="4">
<Item RecordName="Test Record" RecordID="1" />
</Day>
</Month>
</Year>
<Year Year="2011">
<Month Month="1">
<Day Day="3">
<Item RecordName="Another Record" RecordID="2" />
<Item RecordName="Geoffrey Birthday" RecordID="3" />
</Day>
<Day Day="4">
<Item RecordName="Work Day" RecordID="4" />
</Day>
</Month>
<Month Month="12">
<Day Day="6">
<Item RecordName="2nd Test Record" RecordID="5" />
</Day>
</Month>
</Year>
</root>
अब तक, मैं सही काम करने के लिए घोंसले प्राप्त करने में सक्षम नहीं किया गया है। मैं आम तौर पर समूह के साथ समाप्त होता हूं (उदाहरण के लिए, मुझे कई वर्ष = 2011 तत्व मिलते हैं, जब केवल एक होना चाहिए)।
यह नहीं किया जा सकता है, मैं हमेशा नेट साइट पर एक्सएमएल बना सकते हैं ...
उत्कृष्ट! मुझे पता था कि मैं करीब था ... मेरे समूह गलत थे ... धन्यवाद माइकल ... बिल्कुल वही करता है जो मुझे चाहिए। –