I frequently run into a situation where I need to find all entries in a table for a particular key value and then build a simple list of the values seperated by commas.
Usually I display this list either in a Textbox on a form or in a report.

Simple Example: List all Fruit in the Products Table

In my VB code I create a recordset for all Products where the Type is Fruit and then loop through the records and build my string, which in this case would look something like this:
Apple, Orange, Peach, Pare, Strawberry, Mango

Is there a way to turn this VB code into a stored procedure in SQL Server?

I seem to be building lists like this a lot so a stored procedure, to get the processing of of the client onto the server, would be very handy.

Thanks!