Posted by Erland Sommarskog on 01/08/07 08:24
Plamen Ratchev (Plamen@SQLStudio.com) writes:
> Here is one way to accomplish what you need using a function. Be aware of
> the limitation of 8000 characters for varchar. If you are using SQL Server
> 2005 you can use varchar(max) to expand beyond the 8000 character limit.
>...
> SELECT @sReturn = COALESCE(@sReturn + @sDelimiter, '') + col2 FROM Test
> WHERE col1 = @col1 ORDER BY col2
Also beware that this solution relies on undefined behaviour. This may
work - or it may not.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|