Stored Procedure Combining Cell Information
Posted on 2007-04-05
I have a table that holds the features of vehicles. It has two fields. UNTID and DES1. The UNTID field holds the stock number of the vehicle and the DES1 field holds the description of the feature. Here is and example:
123456 Air Conditioning
123456 Cruise Control
154690 Air Conditioning
As you can see a vehicle can have more than one row in the table. Here in lies the problem. I need to extract from the table the information in this format:
123456 Air Conditioning, Cruise Control
I am running MS SQL 2000. I am attempting to do this in a stored procedure and have the results be available in a table with just the UNTID and DES1 on one line per vehicle.
I thought if I could create a temp table and run through a select statement and then add the information into the temp table in the order I wanted it that would work. But I get stuck on the looping through the select statement. Am I doing this the right way or is there an easier way to do this?