Click here to Skip to main content
15,886,137 members

need a Sql query for retrieving data from a string column that store xml content by using where clause

ommi.chiru asked:

Open original thread
Hi All,

Can you please help me out in Sql query that retrieve the data from a string(varchar) column which has xml data as content.

my table column has data like below xml
XML
<Account AccountID="99999999">
  <Details AddressClientID="8888888" Status="INFORCE" AccountID="99999999" />
  <AnalysisCodeValue ObjectType="ACCOUNT" />
  <AccountFee AccountID="99999999" FeeID="TRUSTEEFEE" EffectiveFrom="2011-12-20" Frequency="M" DueDate="2012-10-20" PaidTo="2012-09-30" FeeOverride="NONE" CommissionOverride="NONE" Status="ACTIVE" StartDate="2011-12-20" />
  <Beneficiary>
    <Details AccountID="99999999" Relationship="LPR" Percentage="100.00" BeneficiaryNo="1" />
  </Beneficiary>
  <RelatedParty AccountID="99999999" ClientID="8888888" Relationship="OWNER" />
</Account>


My table looks like
table Name : temp1
col1 (pk) int
col2 (file path) Varchar (100)
col3 (xmldata) Varchar(1000).

Now i need to retrieve the data from third column, based on the attribute value. (i.e) From above xml( which is string column in the table), i need to search my table where RelationShip="LPR".

Thanks in advance.

Regards
Chiranjeevi
Tags: SQL Server, SQL Server 2008

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900