I have the following XML
<?xml version="1.0"?>
<ArrayOfInt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="id">
<int>984026</int>
<int>1005222</int>
</ArrayOfInt>
I pass this to a store procedure with an XML Parameter.
I want to return all the rows that the id is in the int nodes from xml doc
SELECT * FROM
MyTable
WHERE
MyTable.Id IN @XMLDoc.value('(.)[1]', 'int')
This only works if I send one int in the xml
<?xml version="1.0"?>
<ArrayOfInt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="id">
<int>984026</int>
</ArrayOfInt>
But if I run this with the two int nodes, sql concatenates the nodes
The conversion of the nvarchar value '9840261005222' overflowed an int column.