Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 20th, 2004, 01:23 PM
BaronGiles BaronGiles is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 1 BaronGiles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Retrieve Multiple Values into a comma-delimited string

Hello!

I need to retrieve the contents of a particular field (tbAddress.Email) into a comma delimited string (and I'd like to be able to set criteria for the values I retrieve... 'where tbAddress.Status = "Good" ', for instance).

I can write a query that lists the values I want ---
SELECT (tbAddress.Email
FROM tbAddress
WHERE (((tbAddress.Status) = "Good")); ---

but I don't know how to get the multiple rows of data in the query results into a single string... can anyone help?


Paul Giles
Santa Ana, California

Reply With Quote
  #2  
Old July 15th, 2004, 03:20 PM
codejunky codejunky is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 2 codejunky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
one way is using a stored procedure:

create procedure Get_String
AS
declare @OUTPUT varchar(8000)
set @OUTPUT = ''
SELECT @OUTPUT = @OUTPUT + case when @OUTPUT = '' then '' else ',' end + tbAddress.Email
FROM tbAddress
WHERE tbAddress.Status = "Good"

select @OUTPUT

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Retrieve Multiple Values into a comma-delimited string


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT