|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Retrieve Multiple Values into a comma-delimited string |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|