January 24, 2005 at 11:56 am
Hi,
I have a table in the following format.
Title Name
Manager John Doe
Manager Mr. X
Manager Ms. Y
I'd like is to have the resultset in the following format for my Reporting.
Title Name
Manager John Doe;Mr. X; Ms. Y
Any help would be really appreciated. Thanks a lot.
January 24, 2005 at 1:07 pm
See if this helps: http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=156835
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
January 25, 2005 at 5:31 pm
Something like this:
IF EXISTS( SELECT * FROM sysobjects WHERE name = 'T1' )
DROP TABLE T1
GO
CREATE TABLE T1( C1 NCHAR(1) )
SET NOCOUNT ON
INSERT T1 VALUES( 'A' )
INSERT T1 VALUES( 'B' )
INSERT T1 VALUES( 'C' )
DECLARE @str VARCHAR (50) -- attention with size, can trim results
SET @str = ' '
SELECT @str = @str + C1 + '; ' -- any separator here, like '|', ' ', ','
FROM T1
SELECT @str
DROP TABLE T1
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply