Gaurav Gupta

Gaurav Gupta

  • 0
  • 18k
  • 5.9m

Fetch values from Comma Seperated Columns in SQL SERVER

Apr 3 2013 4:05 AM

I have a a table that store values like this:

Name      CategoryId

Gaurav    4,6

Amit      2,4

Ajay      6,2  

2,4,6 (This is the id of category that name is present in their master table)

The Master table of category like this.

Id  CategoryName

2   Motor

4   Scooter

6   Car

I want to fetch all the records from the table first, and want to category name ( not the category id).

Name       CategoryName

Gaurav     Scooter, Car

Amit       Motor, Scooter

Ajay       Car, Motor

How this is done through Stored Procedure...

Answers (2)