I am new to XQuery I am running this query against the XML shown belowSELECT a .b.value('TradeId[1]','VARCHAR(500)') as TradeId,a .b.value('TradeType[1]','VARCHAR(500)') as TradeTypeFROM @XMLstring.nodes(/data/Rpt_Inven/Invens/Inven') a(b) ------------------------------------------------------------------------------------------------------------------------------------------------------ <data> < Rpt_Inven xmlns="urn:schemas.reval.com:reportsRepInven"><Invens> < Inven><Level1/> < Level1SysId _Type=""/><Level2/> < Level2SysId _Type=""/><Level3/> < Level3SysId _Type=""/><Level4/> < Level4SysId _Type=""/><Entity/> < TradeId _Type="" _value="1053">1053</TradeId> < CoParty/><Customer/> <CustomerSysId _Type=""/> < TradeDate _Type="" _value="02/22/2004">2004-02-22</TradeDate> <TerminationDate _Type=""/> < EffectiveDate _Type="" _value="02/25/2004">2004-02-25</EffectiveDate> < MaturityDate _Type="" _value="05/25/2011">2011-05-25</MaturityDate> <ArchivedDate _Type=""/> < TradeDescription _value="7.3 YR FLOATING RATE DEBT: PAY 12M/1Y RPI 4.0000% REAL RATE GBP 100.0 M MAT: 2011-MAY-25">7.3 YR FLOATING RATE DEBT: PAY 12M/1Y RPI 4.0000% REAL RATE GBP 100.0 M MAT: 2011-MAY-25</TradeDescription> <TLGroup/> < AssetClass _value="Interest Rate">Interest Rate</AssetClass> < TradeResetFlag _value="0">0</TradeResetFlag> <NumOfContracts/> < TradeType _value="Debt">Debt</TradeType> < Currency1 _value="GBP">GBP</Currency1> < HasUnwind _value="No">No</HasUnwind> < CashflowsModified _value="No">No</CashflowsModified> <Currency2/> < DealType _value="What-If">What-If</DealType> < DealStatus _value="Active">Active</DealStatus> < TradeStatus _value="Pending">Pending</TradeStatus> < Aud_Version _Type="" _value="2">2</Aud_Version> < InternalTradeId/><CoPartyTradeId/> < PriceIndex/><Future/> <Broker/> < ExclFromLedger _value="Off">Off</ExclFromLedger> < ManualPotentialExpFlag _value="Off">Off</ManualPotentialExpFlag> < ManualFMVFlag _value="Off">Off</ManualFMVFlag> < TradeAcctSysId/><TradeAcctCode/> < Custom1 _AllowBlank="1"/><Custom2 _AllowBlank="1"/> < Custom3 _AllowBlank="1"/><Custom4 _AllowBlank="1"/> < Custom5 _AllowBlank="1"/></Inven> </ Invens></Rpt_Inven> </ data> It dosent return any data but if I remove namespace from <Rpt_Inven> query work fine. How to modify my query to work with NameSpace Thank you
Not sure how to do but the links should help you: http://www.dotnetspider.com/kb/Article1756.aspx http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.server.aspx http://www.developer.com/db/article.php/3531196