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)
 Concat different rows on same field

Author  Topic 

geossl
Yak Posting Veteran

85 Posts

Posted - 2004-01-07 : 02:21:37
Dear All,
There is a table
ID Name
---- -----
1 Peter
2 Mary
3 PauL

I would like to get all these three records and return in a single field, that is,

PeterMaryPaul

Is it possible to do with SQL?

Thanks.

raymondpeacock
Constraint Violating Yak Guru

367 Posts

Posted - 2004-01-07 : 04:45:28
Try this

DECLARE @Result VARCHAR(1000)
SELECT @Result = COALESCE(@Result + name, name) FROM TableName
SELECT @Result



Raymond
Go to Top of Page
   

- Advertisement -