日期:2014-05-18 浏览次数:20391 次
declare @xml xml set @xml='<FLIGHT> <DATETIME> 2007-11-22 09:27:04 </DATETIME> <METHOD> MOD </METHOD> <TYPE> A </TYPE> <FLIGHTINFOR> <FLIGHTATTR> 21 </FLIGHTATTR> <FLIGHTTYPE> 0 </FLIGHTTYPE> <FLIGHTDATETIME> <PLANDATE> 2007-11-22 </PLANDATE> <ADT /> <EDT> 2007-11-22 10:33:00 </EDT> <SDT> 2007-11-22 09:30:00 </SDT> </FLIGHTDATETIME> </FLIGHTINFOR> </FLIGHT>' SELECT testByjinjazz.value('DATETIME[1]', 'DATETIME') DATETIME, testByjinjazz.value('METHOD[1]', 'nvarchar(10)') METHOD, testByjinjazz.value('TYPE[1]', 'nvarchar(10)') TYPE, testByjinjazz.value('FLIGHTINFOR[1]/FLIGHTATTR[1]','int') FLIGHTATTR, testByjinjazz.value('FLIGHTINFOR[1]/FLIGHTTYPE[1]','int') FLIGHTTYPE, testByjinjazz.value('FLIGHTINFOR[1]/FLIGHTDATETIME[1]/PLANDATE[1]','nvarchar(10)') PLANDATE, testByjinjazz.value('FLIGHTINFOR[1]/FLIGHTDATETIME[1]/ADT[1]','DATETIME') ADT, testByjinjazz.value('FLIGHTINFOR[1]/FLIGHTDATETIME[1]/EDT[1]','DATETIME') EDT, testByjinjazz.value('FLIGHTINFOR[1]/FLIGHTDATETIME[1]/SDT[1]','DATETIME') SDT FROM @xml.nodes('//FLIGHT') AS R(testByjinjazz) /* DATETIME METHOD TYPE FLIGHTATTR FLIGHTTYPE PLANDATE ADT EDT SDT ----------------------- ---------- ---------- ----------- ----------- ---------- ----------------------- ----------------------- ----------------------- 2007-11-22 09:27:04.000 MOD A 21 0 2007-11-2 1900-01-01 00:00:00.000 2007-11-22 10:33:00.000 2007-11-22 09:30:00.000 (1 行受影响) */
------解决方