Being a part of a multinational company sometimes it is hard to keep track of returns. I had written a query that take a list of return numbers and generates results of items not in the system.
declare @myString varchar(100)='123,RTV0267111,RTV0269188,RTV0284929,RTV0284782'
;WITH
cte AS
( SELECT CAST(N'' +Replace(@myString,',','') + '' as XML) AS vals )
SELECT s.a.value('.', 'NVARCHAR(50)') as num
FROM cte CROSS APPLY vals.nodes('/H/r') S(a)
EXCEPT
select DISTINCT NumAtCard from ORIN
WHERE FatherCard = 'GTHead' AND DocType = 'I' AND CANCELED = 'N' ORDER BY NUM;