Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sp_send_dbmail , a query into @recipients

Status
Not open for further replies.

henin

MIS
Oct 30, 2007
35
IL
Hi everyone,
using sp_send_dbmail , for the @recipients parameter i tried a query as follows:
Code:
DECLARE @mailist VARCHAR(2000)
SET @mailist=
'
select email 
from 
server.db.dbo.table
where
lastname=' + '''' + 'aaa' + ''''

exec msdb.dbo.sp_send_dbmail 
@profile_name='my_profile',
@recipients=@mailist,
@...
i didnt get any error message but the mails didnt arrive...
any idea why ?
thanks
 
What value gets put into the variable? Is it a legit address? What's in the Database Mail log?

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

My Blog
 
Hi mrdenny,
And thanks for your response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top