Chris...hats off to yaaaaaaaaaaaaaaaaa 🙂 so awesome and superb fast...I simply praised you for the awesome query 🙂 Wish I could learn SQL like ya 🙂
ChrisM@Work (3/7/2013)
DECLARE @ItemCod VARCHAR(8000) = 'T1;T2;T3;'
DECLARE @ItemName VARCHAR(8000) = 'Pencil Box;Eraser;Mouse Pad;'
DECLARE @Amount VARCHAR(8000) = '1900;2000;8900;'
SELECT
c.ItemNumber,
ItemCod = c.Item,
ItemName = n.Item,
Amount = a.Item
FROM dbo.DelimitedSplit8K(@ItemCod,';') c
INNER JOIN dbo.DelimitedSplit8K(@ItemName,';') n ON n.ItemNumber = c.ItemNumber
INNER JOIN dbo.DelimitedSplit8K(@Amount,';') a ON a.ItemNumber = c.ItemNumber
WHERE c.Item <> ''
-- Results
ItemNumberItemCodItemNameAmount
1 T1 Pencil Box 1900
2 T2 Eraser 2000
3 T3 Mouse Pad 8900
The function DelimitedSplit8K is discussed in this article[/url].