This is probably simple and I just don't get the braces right, but since I have virtually no experience in querying SQL SERVER XML data, it's driving me insane.
I have a simple table with an XML typed column NoSqlField. This contains either NULL or
<root version="1.0">
<entry key="mykey">1</entry>
</root>
I want all rows in the table that have a <entry key="mykey">1</entry> value in their NoSqlField column.
A (rather stupid as it uses .ToString()) LINQ query using
where h.NoSqlField.ToString().IndexOf("<entry key=\"mykey\">1</entry>") > -1
returns a result, so it's definitely there.
How can I run the same query in T-SQL? I have tried
SELECT * FROM mytable WHERE
NoSqlField.value('(//entry[@key=mykey])[1]','varchar(1)') = '1'
in various variations (with and without slashes, full path,...) but never got a single returned row.