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.
Author |
Topic |
fralo
Posting Yak Master
161 Posts |
Posted - 2014-08-07 : 08:57:59
|
Hi,I need help trying to query data from an XML field in my table called AUDIT.log. The data looks like:<row UNIQUEKEY="238sdf923kg9"> <column name="NARRATIVE" old="Not available" new="Sample text"/> <column name="EDITTIME" old="1899-12-30 14:23:34.482" new="1899-12-30 14:28:15.573" /></row>I'm only interested in getting the 'new' field for the narrative.Thanks so much for any help you can provide. I appreciate it tremendously. |
|
stepson
Aged Yak Warrior
545 Posts |
Posted - 2014-08-07 : 12:17:55
|
[code]DECLARE @xmlVar AS XML ='<row UNIQUEKEY="238sdf923kg9"><column name="NARRATIVE" old="Not available" new="Sample text"/><column name="EDITTIME" old="1899-12-30 14:23:34.482" new="1899-12-30 14:28:15.573" /></row>'SELECT t.u.value('@new','varchar(50)') as columnNew FROM @xmlVar.nodes('row/column') t(u)[/code]and the output:[code]Sample text1899-12-30 14:28:15.573[/code]sabinWeb MCP |
|
|
|
|
|