Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 XML

Author  Topic 

hai_venkat
Starting Member

10 Posts

Posted - 2010-11-24 : 09:16:22
Hi,
I want to find a tag in a xml whether the vlue exists or not.
This XML is already stored stored in the table with XML datatype.
Not passed through a parameter.

here i want to check the whether dataeccepted tag contains a value or not.

here the sample XML.

<SB_DispatchListReply>
<MsgStatus>NORMAL</MsgStatus>
<StatusDetails />
<DispatchDateBegin>07/20/2010</DispatchDateBegin>
<DispatchDateEnd>07/27/2010</DispatchDateEnd>
<TotalCount>1</TotalCount>
<More>N</More>
<DataFormat>5</DataFormat>
<DispatchData />
<Dispatches>
<Dispatch>
<DispatchNumber>D467861493</DispatchNumber>
<ManufacturerReference>37160503</ManufacturerReference>
<ManufacturerName>NEW</ManufacturerName>
<Brand>RCA</Brand>
<ProductNumber>27F554T</ProductNumber>
<ProductName />
<PurchaseDate>04/21/2008</PurchaseDate>
<ProofOfPurchase />
<RecallNumber />
<AuthorizationNumber>51818905</AuthorizationNumber>
<ServiceContractNumber />
<ServiceContractExpiryDate />
<PaymentType>Service Contract</PaymentType>
<PaymentTerms />
<CompanyName />
<ConsumerLastName>DLABAJ</ConsumerLastName>
<ConsumerFirstName>MARY</ConsumerFirstName>
<ConsumerAddressLine1>501 W LAMPASAS</ConsumerAddressLine1>
<ConsumerAddressLine2>APT E3</ConsumerAddressLine2>
<ConsumerAddressCity>ENNIS</ConsumerAddressCity>
<ConsumerAddressState>TX</ConsumerAddressState>
<ConsumerAddressZip>75119</ConsumerAddressZip>
<ConsumerPhone>2147930061</ConsumerPhone>
<ConsumerWorkPhone />
<ConsumerAlternatePhone>9728751438</ConsumerAlternatePhone>
<ConsumerFax />
<ConsumerEmail />
<CustomerInstructions />
<DispatchDate>07/26/2010</DispatchDate>
<ScheduledServiceDate>07/28/2010</ScheduledServiceDate>
<SlotType>Morning</SlotType>
<DispatchStatus>Accepted</DispatchStatus>
<SubStatus />
<DateAccepted>07/26/2010</DateAccepted>
<ZoneDescription>Default Zone</ZoneDescription>
<DealerPurchasedFrom>WALMART STORES</DealerPurchasedFrom>
<AddressDirections />
<ProblemDescription>POWERS ON THEN SHUTS OFF</ProblemDescription>
<ServiceExplanation />
<RejectReason />
<RenotifyReason />
<SerialNumber>ET066I036E43PU</SerialNumber>
<ProductLine>TELEVISION</ProductLine>
<FirstTimeSent>Y</FirstTimeSent>
<DealerLocationNumber>52809228</DealerLocationNumber>
<ZoneNumber>DEFAULT</ZoneNumber>
<ComplaintCode />
<ContractPurchaseDate>21-APR-2008</ContractPurchaseDate>
<AuthorizedAmount>155.00</AuthorizedAmount>
<MailingLabelMethod />
<PreferredContactMethod>Customer Alternate Phone</PreferredContactMethod>
<OutgoingPackagingTrackingNum />
<OutgoingPackagingShipStatus />
<IncomingProductTrackingNum />
<IncomingProductShipStatus />
<OutgoingProductTrackingNum />
<OutgoingProductShipStatus />
<Entitlements>
<Entitlement>
<TransactionType>5 : BULB REPLACEMENT NOT ALLOWED ON THIS CONTRACT</TransactionType>
<TransactionDescription>BULB REPLACEMENT IS NOT INCLUDED</TransactionDescription>
</Entitlement>
<Entitlement>
<TransactionType>6 : DAMAGE CAUSED BY POWER SURGE COVERED FROM DATE OF PURCHA</TransactionType>
<TransactionDescription>PRIMARY COVERAGE BEGINS DATE OF PURCHASE</TransactionDescription>
</Entitlement>
<Entitlement>
<TransactionType>EXCEPTIONAL LABOR UNDER</TransactionType>
<TransactionDescription>COD</TransactionDescription>
</Entitlement>
<Entitlement>
<TransactionType>EXCEPTIONAL PARTS UNDER</TransactionType>
<TransactionDescription>COD</TransactionDescription>
</Entitlement>
<Entitlement>
<TransactionType>LABOR UNDER</TransactionType>
<TransactionDescription>NEW</TransactionDescription>
</Entitlement>
<Entitlement>
<TransactionType>PARTS UNDER</TransactionType>
<TransactionDescription>NEW</TransactionDescription>
</Entitlement>
</Entitlements>
<Services />
<TechnicianId />
<RouteNumber />
<CustomerInstructions />
<ServiceSiteId>2</ServiceSiteId>
<ServiceRequestId>03</ServiceRequestId>
<ReturnId />
<Comments />
<Parts />
</Dispatch>
</Dispatches>
</SB_DispatchListReply>

Thanks in advance.

Venkat

Venkat

Sachin.Nand

2937 Posts

Posted - 2010-11-24 : 09:28:19
So which value you want to check whether it exists? And also any preconditions on what to use and what not?


PBUH

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-11-24 : 09:35:22
i think what you need is exists function

http://www.sqlmusings.com/2009/04/08/sqlxml-how-to-use-sql-server-xml-function-exist/

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -