-1
I have a cursor where it brings me data of a request (mother table) and the order items in xml(daughter table) currently the cursor brings request by request with fetch next, but the daughter table comes with all the items (column "test") and I would like it to come item by item. for example:
request 1 item 1
order 1 item 2
request 1 item 3
The idea is to use a temporary table, but I have no idea how to do this. Could someone give a light? Here’s an image of the current result and code.
DECLARE crs CURSOR
select distinct a.DocEntry
,cardcode,cardname,a.CreateDate,DATEDIFF(day,a.CreateDate,GETDATE()) Dias_Em_Aberto,d.SlpName
,CONCAT(ISNULL(substring((select '/'+ ItemCode from RDR1 where RDR1.DocEntry = a.DocEntry for xml path ('')),2,9999),'')+' '+substring((select '-'+ CAST(Onhand as varchar(200) )from OITM where OITM.ItemCode = b.ItemCode for xml path ('')),2,9999),'') teste
from ordr a........
Make your XML available so we can suggest something
– Sorack
"xml" would be the test column, each item code comes separated by bar, but wanted it to be a row if I got it wrong please explain me
– Douglas Souza
I think you’d better put some more information in your question: 1) The structure of the tables involved. 2) sample data from these tables. 3) the expected result
– Sorack
Good morning! The structure would be kind of impossible because they are extremely large, are SAP B1 tables. I will add more data and also put the result.
– Douglas Souza