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
 SQL Server Development (2000)
 ROW to Column

Author  Topic 

GenerationWithoutName
Starting Member

26 Posts

Posted - 2002-10-09 : 07:38:46

Consider SELECT Statement like this :
SELECT ItemMerk FROM tblItemMerk

it shows, ...
ItemMerk
--------------------
HONDA
KAWASAKI
SUZUKI
YAMAHA

Can i display like this :
HONDA, KAWASAKI, SUZUKI, YAMAHA
rather than
HONDA
KAWASAKI
SUZUKI
YAMAHA



DIJE

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-10-09 : 07:45:06
If you mean to just display a CSV list of the columns, then This article suggests a good method using the COALESCE function. If, however, you are looking to create a pivot table, then read Dynamic Cross-Tabs/Pivot Tables

Jay White
{0}
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-10-09 : 09:20:46
Or:

http://www.sqlteam.com/item.asp?ItemID=11021

Modesty prevented Jay from posting this earlier.

Go to Top of Page

GenerationWithoutName
Starting Member

26 Posts

Posted - 2002-10-09 : 10:25:44
thank's ALL. thank you very much.
I LOVE YOU GURU's

DIJE
Go to Top of Page

Shaner
Starting Member

9 Posts

Posted - 2002-10-09 : 15:14:16
If all you want to do is CSV the values...here is some simple logic to use as well.
------------------------------------

DECLARE @list varchar(8000)

SET CONCAT_NULL_YIELDS_NULL OFF
SELECT @list = '' + @list + ItemMerk + ',' FROM tblItemMerk

SET @list = LEFT(@list,LEN(@list)-1)

PRINT @list

Go to Top of Page
   

- Advertisement -