|
Posted by Erland Sommarskog on 05/06/06 00:26
(cybergoth_0@yahoo.co.uk) writes:
> I have a table with a column called AccessTypes which contains a single
> letter.
>
> I want to return these accesstypes from a query into one string. e.g.
>
> if there were 3 entries of A, S and D
>
> I want to select them and instead of returning 3 rows, I want just 1
> string like "ASD"
>
> can it be done?
If you are on SQL 2000, you need to use a cursor. The trick with
SELECT @x = @x + 'd' may work, but the result of this expression is
undefined, so you may get something else.
On SQL 2005, you can use FOR XML PATH as shown in the link posted by
Mark.
--
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
Navigation:
[Reply to this message]
|