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)
 Please help !!

Author  Topic 

akki
Starting Member

14 Posts

Posted - 2004-04-08 : 06:16:04
Hello Guys,

I got a table as

Category
--------
ABC
DEF
XYZ

etc.

How can I write a query to get the output as

Category
--------
ABC, DEF, XYZ

I have no clue . . . Please help . . .

Thanks,
akki.

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2004-04-08 : 06:49:57
check:
http://www.sqlteam.com/item.asp?ItemID=11021

He is a fool for five minutes who asks , but who does not ask remains a fool for life!<N>

http://www.sqldude.4t.com
Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-04-08 : 08:26:01
Thanks for the link to my article ... however, if akki only wants a single row for the whole table, this is much easier:

create table #akki (
category char(3))
insert #akki
select 'abc' union select 'def' union select 'xyz'

declare @category varchar(15)

select
@category = coalesce(@category + ', ','') + category
from
#akki

select
@category as Category

drop table #akki

 


Jay White
{0}
Go to Top of Page
   

- Advertisement -