Link to home
Start Free TrialLog in
Avatar of LeeHopkins
LeeHopkinsFlag for United States of America

asked on

query list into a string

I have a query that brings back a list of email address based on some factor I need to creat a list
x@.com;y@.com;z@.com........
from a result set
x@.com
y@.com
z@.com
......
with out haveing to do a cursor
Avatar of DonKronos
DonKronos
Flag of United States of America image

do something like this:

declare @list varchar(1000)

select @list = @list + emailaddress + ';' from table1

set @list = substring(@list,1, (len(@list) - 1))
Avatar of LeeHopkins

ASKER

no go

declare @list varchar(1000)

select @list = @list + p_emailaddress + ';' from Purge_Email

set @list = substring(@list,1, (len(@list) - 1))

it should have returned 4 records
declare @list varchar(1000)
select @list = Coalesce(@list + ', ', '') + p_emailaddress
from purge_email where charindex('input_output',P_customer)> 0
select @list

Almost works but not giving distinct
ASKER CERTIFIED SOLUTION
Avatar of DonKronos
DonKronos
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial