LeeHopkins
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
x@.com;y@.com;z@.com......
from a result set
x@.com
y@.com
z@.com
......
with out haveing to do a cursor
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 = @list + p_emailaddress + ';' from Purge_Email
set @list = substring(@list,1, (len(@list) - 1))
it should have returned 4 records
ASKER
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
select @list = Coalesce(@list + ', ', '') + p_emailaddress
from purge_email where charindex('input_output',P
select @list
Almost works but not giving distinct
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
declare @list varchar(1000)
select @list = @list + emailaddress + ';' from table1
set @list = substring(@list,1, (len(@list) - 1))