Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

put a colum of data and insert it into a single field with comma seperators

Posted on 2009-05-14
3
Medium Priority
?
166 Views
Last Modified: 2012-05-07
I have a table  called [table_a] and it has a column name [product],

when i run this statement  
'SELECT product FROM table_a'

it returns

product
A0023
GG990
HHG176
KKJ1212

what statement would i need to return one record in the below format

A0023,GG990,HHG176,KKJ1212

0
Comment
Question by:meteorelec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Expert Comment

by:cdaly33
ID: 24385748
I've used the method in this article many times with great results.
http://www.sqlteam.com/article/using-coalesce-to-build-comma-delimited-string
0
 
LVL 41

Accepted Solution

by:
ralmada earned 2000 total points
ID: 24385780
Please give this a try:
SELECT Product = REPLACE( 
	( 
	SELECT 
	Product AS [data()] 
	FROM 
	Table_a c 
	ORDER BY 
	c.Product 
	FOR XML PATH ('') 
	), ' ', ',')
 

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question