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

Can SQL email me when certain database conditions are true? (novice)

Status
Not open for further replies.

lori

Programmer
Dec 18, 1999
3
US
I'm very new to SQL.  No training yet.  I'd appreciate guidance on the following.  Once per day, I'd like SQL to examine records in a table and send email if certain conditions are true.  I'm trying to set up a 'reminder' system to bug my intranent content providers to send their content changes to me so I can post them in time.  This content could be updated on a weekly, monthly, or yearly basis and I don't want to use my Outlook Calendar.  I want to create records in an SQL table and have an SQL Job (?) execute an SQL stored procedure (?) to query my reminder table and send email via Outlook.  For example (in English): If today is Thursday, query the reminder table for all RemindOn='Thursday' then process each of those records by sending an email note to the RemindWho.  Sounds simple, but I'm not sure where to begin.  Thanks in advance.
 
Lori,<br>I believe you can use this with a little modification.<br>Use 'pubs' to test and then &quot;lift&quot; it to your application.<br>Open pubs - tables - then right click on 'titles' and select 'All tasks'.&nbsp;&nbsp;&nbsp;Select 'manage triggers'.&nbsp;&nbsp;Use code below to create trigger:&nbsp;&nbsp;(I tested this on another server - if you'll send your email address, I'll send SQL email message to you when I change table - &quot;<A HREF="mailto:saldridg@idwr.state.id.us">saldridg@idwr.state.id.us</A>&quot;<br>Steve A.<br><br>USE pubs<br>IF EXISTS (SELECT name FROM sysobjects<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE name = 'reminder' AND type = 'TR')<br>&nbsp;&nbsp;&nbsp;&nbsp;DROP TRIGGER reminder<br>GO<br>CREATE TRIGGER reminder<br>ON titles<br>FOR INSERT, UPDATE, DELETE <br>AS<br>&nbsp;&nbsp;&nbsp;&nbsp;EXEC master..xp_sendmail 'MaryM', <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Message to user.'<br>GO<br><br>&nbsp;&nbsp;<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top