Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Concatenation Query

Author  Topic 

Madhav
Starting Member

38 Posts

Posted - 2007-08-02 : 09:28:11
Hi ,

i had a table product
the data in that table is as below
col1 col2
------------
p1 1.0
p1 2.0
p1 3.1
aaa 1.0
aaa 1.5


i need to get the result as
col1 col2
---------------
p1 1.0,2.0,3.1
aaa 1.0,1.5

please give me a query

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-02 : 09:31:34
Where do you want to show data?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Madhav
Starting Member

38 Posts

Posted - 2007-08-02 : 09:43:17
the first one is a table
i want query to get the second table using first table

quote:
Originally posted by madhivanan

Where do you want to show data?

Madhivanan

Failing to plan is Planning to fail

Go to Top of Page

sshelper
Posting Yak Master

216 Posts

Posted - 2007-08-02 : 09:43:34
You can create a user-defined function that will take as a parameter col1 and which will return the concatenated values of col2. Here's a link that does something similar:

http://www.sql-server-helper.com/tips/comma-delimited-output.aspx

SQL Server Helper
http://www.sql-server-helper.com
Go to Top of Page
   

- Advertisement -