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)
 How can i combine rows in one column

Author  Topic 

muzaffar_ali99
Starting Member

33 Posts

Posted - 2006-11-27 : 02:10:23
I have one table of choices that contatins choices against options.
Wht i want to do is gather all the choices in one row with comma separated but not using cursors.
Tbl_Choice
Choice_Id Option_Id Label
1 1 Choce1
2 1 Choice2
3 1 Choice3
4 1 Choice4
When i select by giving the query it gives
Select * from tbl_choice where option_id=1
it gives me four rows but i need one row data in the form of
'Choice1,Choice2,Choice3,Choice4'

Regards

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-27 : 02:19:10
See this topic http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=53293


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

muzaffar_ali99
Starting Member

33 Posts

Posted - 2006-11-27 : 03:50:08
Thanks i found the solution from above topic.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-27 : 07:23:13
Note that if the concatenated string exceeds more than 8000 characters, you need to use more than one variable.
If you use front end application, do concatenation there

Madhivanan

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

- Advertisement -