Вот один из способов сравнить таблицу БД и запрос XML.Может быть, не совсем то, что вы ищете, но это даст вам преимущество.
SQL
DECLARE @xml_request XML = N'<Students>
<Student id="101" course="Computer" Year="2016"/>
<Student id="102" course="Electrical" Year="2017"/>
<Student id="103" course="Mechanical" Year="2019"/>
</Students>';
DECLARE @mockTbl TABLE (id INT PRIMARY KEY, course VARCHAR(30), [year] CHAR(4));
INSERT INTO @mockTbl (id, course, [year])
VALUES
(101, 'Computer', '2016')
, (102, 'Electronics', '2017')
, (103, 'Mechanical', '2019');
;WITH rs AS
(
SELECT c.value('@id', 'INT') AS id
, c.value('@course', 'VARCHAR(30)') AS course
, c.value('@Year', 'CHAR(4)') AS [year]
FROM @xml_request.nodes('/Students/Student') AS t(c)
)
(SELECT *, 'no match' AS result FROM rs
EXCEPT
SELECT *, 'no match' FROM @mockTbl)
UNION ALL
(SELECT *, 'match' FROM rs
INTERSECT
SELECT *, 'match' FROM @mockTbl);
Вывод
+-----+------------+------+------------------+
| id | course | year | result |
+-----+------------+------+------------------+
| 102 | Electrical | 2017 | no match |
| 101 | Computer | 2016 | match |
| 103 | Mechanical | 2019 | match |
+-----+------------+------+------------------+