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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

E-mail from stored procedure

Status
Not open for further replies.

puredesi5

Programmer
Sep 26, 2001
50
US
Does anyone know if I can send an e-mail from stored procedure? What i like to do is count number of records in a table for a particular day. If there are more than 10 records, I need to send an e-mail,
Is this possible, any other suggestion would be appreciated too.
Select @a_count = count(*) from tbla where ----

If @a_count > 10 send e-mail

Puredesi
 
here is an example

alter proc sendmails as
declare @count int
set @count = (Select count(*) from tble where ---)
if @count >10
begin
exec ('master..xp_startmail')
exec ("master..xp_sendmail @recipients ='email address want to send',@message='Test',@query='select * from pubs.dbo.publishers'")
end


Check books online for more detail about xp_sendmail,xp_startmail and xp_stopmail
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top