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)
 Table output into a single string

Author  Topic 

lkozhush
Starting Member

6 Posts

Posted - 2003-10-02 : 01:51:38
Hi there,

have a quick question. trying to output table rows as a single string

loginame
--------
dmeadows
kmavrona
lkozhush
mxd

should be dmeadows, kmavrona, lkozhush, mxd.

Thank you in advance.

Lkozhush.

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2003-10-02 : 03:01:17
[code]declare @s varchar(8000)

set @s = ''

select @s = @s + loginame + ', ' from t

select left(@s, len(@s) - 1)[/code]
Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-10-02 : 14:52:05
Or:

DECLARE @str varchar(8000)

SELECT @str = ISNULL(@str + ',', '') + loginame FROM tableName

Owais


Make it idiot proof and someone will make a better idiot
Go to Top of Page

lkozhush
Starting Member

6 Posts

Posted - 2003-10-02 : 19:39:28
quote:
Originally posted by Stoad

declare @s varchar(8000)

set @s = ''

select @s = @s + loginame + ', ' from t

select left(@s, len(@s) - 1)




Thank you for your assistance. Cheers. lkozhush
Go to Top of Page

lkozhush
Starting Member

6 Posts

Posted - 2003-10-02 : 19:40:04
quote:
Originally posted by mohdowais

Or:

DECLARE @str varchar(8000)

SELECT @str = ISNULL(@str + ',', '') + loginame FROM tableName

Owais


Make it idiot proof and someone will make a better idiot



Thank you for your assistance. Cheers. lkozhush
Go to Top of Page
   

- Advertisement -