SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query XML record
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

s72
Starting Member

Romania
1 Posts

Posted - 11/16/2012 :  04:56:19  Show Profile  Reply with Quote
Hi,
First my name is Marian and I am from Romania.
I have a question, for me is complicated
I dont have any experience in xml/sql and I need some help to complete my project
I have a table named mytable with 3 columns
ID identity record
STATE XML record
STATUS boolean

And I have inserted in mytable 2 records
ID | STATE | STATUS |
=====================
1 | <?xml version="1.0" encoding="ISO-8859-1"?> <ADD="False" SET="False" SN="123456"/> | true
2 | <?xml version="1.0" encoding="ISO-8859-1"?> <ADD="False" SET="False" SN="123457"/> | false

My question is :
How can I create a SELECT statment to return SN value from STATE record WHERE ID = 1 for example.

Thanks

Edited by - s72 on 11/16/2012 04:58:33

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/16/2012 :  06:48:26  Show Profile  Reply with Quote
The XML does not appear to be well-formed, so you cannot use SQL's XML features to query this data.

What kind of project is it? Is it an academic project? Consult the professor or person who gave you the XML data and ask them for well-formed XML.

If they are unable to provide you with well-formed XML, you should use string functions in SQL to parse it and get the data you need.
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8679 Posts

Posted - 11/16/2012 :  06:57:31  Show Profile  Visit webfred's Homepage  Reply with Quote
You have stated:
quote:

I have a table named mytable with 3 columns
ID identity record
STATE XML record
STATUS boolean

And I have inserted in mytable 2 records
ID | STATE | STATUS |
=====================
1 | <?xml version="1.0" encoding="ISO-8859-1"?> <ADD="False" SET="False" SN="123456"/> | true
2 | <?xml version="1.0" encoding="ISO-8859-1"?> <ADD="False" SET="False" SN="123457"/> | false


I would like to see the insert statement and the table create statement because for me it wasn't possible to insert that example data into an xml column...


Too old to Rock'n'Roll too young to die.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000