0

I've got a table with an xml column called data (xml has got id node) and second table with idSecond column.

I would like to perform join between these two tables so that data[id] = secondTable.ID

What would be the syntax for this in SQL Server 2005 ?

thanks for any hints

1 Answer 1

3

Use xml.value() method to project the node id, then join on the projected value. Eg:

with x as (
select xmlcolumn.value(N'xquery_for_node...', N'type') as id,
   ...
from xmltable)
select ...
from x join secondtable on x.id = ...

Actual syntax and xquery used depends on the schema of your tables and the XML content. If there are multiple node ids to project then use xml.nodes() in a cross apply instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.