Re: SELECT records to commaseparated string??
From: avnrao (avn_at_newsgroups.com)
Date: 11/03/04
- Next message: Roji. P. Thomas: "Re: Strange problem: missing content in colums?"
- Previous message: Tibor Karaszi: "Re: Collation Conflict on Cross Database Join"
- In reply to: Kjell Brandes: "SELECT records to commaseparated string??"
- Next in thread: Kjell Brandes: "Re: SELECT records to commaseparated string??"
- Reply: Kjell Brandes: "Re: SELECT records to commaseparated string??"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 3 Nov 2004 14:12:50 +0530
not sure if you know this..
Declare @ConcatString nvarchar(4000)
SET @ConcatString = ''
Select @ConcatString = @ConcatString +
(CASE WHEN @ConcatString = '' THEN
Convert(Varchar(10),ID)
ELSE
',' + Convert(Varchar(10),ID)
END)
From Table
print @ConcatString
Av.
http://avdotnet.rediffblogs.com
http://www28.brinkster.com/avdotnet
"Kjell Brandes" <kjell@brandes.tv> wrote in message
news:uS8lD0XwEHA.1452@TK2MSFTNGP11.phx.gbl...
> Is there a simple way to do a "select columnname from tablename" which
> returns 10 rows getting this rows into a commaseparated string.
>
> ex.
> above select would return:
> columnname
> 1
> 2
> 3
> 4
> 5
> 6
> .
> .
> .
> .
> and so on.....
>
> I would like it in this form
> 1, 2, 3, 4,.........
>
> I know UDFs or PROCs is a way I just wonder if there might be a simplier
> solution to this.
>
> Thanx
> Kjell Brandes
>
>
- Next message: Roji. P. Thomas: "Re: Strange problem: missing content in colums?"
- Previous message: Tibor Karaszi: "Re: Collation Conflict on Cross Database Join"
- In reply to: Kjell Brandes: "SELECT records to commaseparated string??"
- Next in thread: Kjell Brandes: "Re: SELECT records to commaseparated string??"
- Reply: Kjell Brandes: "Re: SELECT records to commaseparated string??"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|