April 21, 2009 at 11:54 pm
Hi,
In this below xml, how can I select the list of employee ids (as int) where location id is 3? I can get all the list of empids using this query
SELECT tbl.rows.value('.', 'int')
FROM @company.nodes('/Company/Locations/Location/Department/Employees/EmpId') AS tbl(rows)
How do i add an where/exist condition (LocId=3) to this above query?
DECLARE @company XML
April 22, 2009 at 12:06 am
Nevermind. This one worked.
SELECT tbl2.rows2.value('.', 'int')
FROM @company.nodes('/Company/Locations/Location/Department') AS tbl(rows)
CROSS APPLY tbl.rows.nodes('./Employees/EmpId') AS tbl2(rows2)
WHERE tbl.rows.exist('../LocId[text()="3"]') = 1
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy