By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,575 Members | 1,968 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,575 IT Pros & Developers. It's quick & easy.

return into one string

P: n/a
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?

May 5 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Have a look here

http://www.aspfaq.com/show.asp?id=2529

May 5 '06 #2

P: n/a
(cy*********@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, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
May 5 '06 #3

P: n/a
Why do you wish to destroy First Normal Form (1NF) with a concatendated
list structure? It is the foundation of RDBMS, after all.

Why are you formatting data in the back end? The basic principle of a
tiered architecture is that display is done in the front end and never
in the back end. This a more basic programming principle than just SQL
and RDBMS.

May 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.