May 1, 2012 at 10:30 am
I have two tables , the schema is attached.
I would like to get the result as the second attachment.
May 1, 2012 at 10:33 am
Now, show us what you have done so far in an attempt to solve your problem.
May 1, 2012 at 10:39 am
This?
SELECT P.Product_id , CrsApp.Item , PD.description
FROM Product P
CROSS APPLY dbo.DelimitedSplit8K (P.Category , ',') CrsApp
JOIN Prod_desc PD
ON CrsApp.Item = PD.Category
ORDER BY CrsApp.Item ,P.Product_id , PD.description
And the code for dbo.DelimitedSplit8K is here --> Tally OH! An Improved SQL 8K βCSV Splitterβ Function[/url]
Edit : Added the link to DelimitedSplit8K
Edit 2: Changed the ORDER BY order
May 1, 2012 at 4:21 pm
I wish I have created the tables.
But the tables have already existing there like that given to us, I just help with a query.
I cannot change the table structure in this case.
If I could, I wouldn't have posted the message
May 1, 2012 at 4:37 pm
Thank you, ColdCoffee,
It works perfectly.
The function seems a very useful one
May 1, 2012 at 5:31 pm
CELKO (5/1/2012)
Here is what you should have posted.
If you had bothered to look, the op posted some pretty good code for the post including sample data. π
Now do a simple join. In the future, please post code and not pictures.
Agreed but that's only a part of the problem posted. Let's see your solution to normalize the requiest, please. π
--Jeff Moden
Change is inevitable... Change for the better is not.
May 1, 2012 at 5:34 pm
sqlfriends (5/1/2012)
Thank you, ColdCoffee,It works perfectly.
The function seems a very useful one
Please forward your thanks to the poster above me, who invented it π
And the previous poster is ----> Jeff π
May 2, 2012 at 10:38 am
Thank you a million, Jeff.
May 25, 2012 at 5:45 pm
Thank you both for the feedback. CC, well done and well played. Team effort here. π
--Jeff Moden
Change is inevitable... Change for the better is not.
May 26, 2012 at 7:16 am
sqlfriends (5/1/2012)
I have two tables , the schema is attached. I would like to get the result as the second attachment.
Why do you have comma separated values in your database?
Viewing 10 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply