Skip to Content
Author's profile photo Jonathan Brotto

When you have a list of returns but not sure which ones have been returned

CMR SAP query.PNGBeing 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′  
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) 
select DISTINCT NumAtCard from ORIN
WHERE FatherCard = ‘GTHead’ AND DocType = ‘I’ AND CANCELED = ‘N’  ORDER BY NUM;

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.