473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Email on insert in a table

Hi,

I wish to use email functionality of sql to send me an email when an insert
is performed on a particular table. I know that a proc and may be a trigger
is required.

Can someone please provide me some hints.

Thanks,

Guju
Jul 23 '05 #1
3 1926
It's not a good idea to send email from a trigger. Email is an
inherently asynchronous medium so there is really no need to hold open
a transaction while sending an email. Also, if the INSERT is performed
inside a transaction which later gets rolled back then the email will
have been sent for an INSERT that never actually happened.

Schedule a process that regularly checks for new rows and sends out
emails accordingly. For example you can use SQL Agent to call such a
process every minute if required.

More about emailing from SQL Server here:
http://www.aspfaq.com/show.asp?id=2403

--
David Portas
SQL Server MVP
--

Jul 23 '05 #2
David,

What would the code look like in the proc?

Thanks,

"David Portas" <RE****************************@acm.org> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
It's not a good idea to send email from a trigger. Email is an
inherently asynchronous medium so there is really no need to hold open
a transaction while sending an email. Also, if the INSERT is performed
inside a transaction which later gets rolled back then the email will
have been sent for an INSERT that never actually happened.

Schedule a process that regularly checks for new rows and sends out
emails accordingly. For example you can use SQL Agent to call such a
process every minute if required.

More about emailing from SQL Server here:
http://www.aspfaq.com/show.asp?id=2403

--
David Portas
SQL Server MVP
--

Jul 23 '05 #3
To call xp_sendmail? See Books Online for examples and syntax - there
are too many different options to cover here. I recommend
xp_smtp_sendmail instead - I've found it much easier to set up and more
reliable than xp_sendmail. Both are covered by the links in the article
I posted before.

--
David Portas
SQL Server MVP
--

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
2
by: Michael Bourgon | last post by:
I need to build an automated email that gives the completion messages when a database is restored (i.e. "Executed as user: sa. Executing RESTORE DATABASE DB1 FROM...
4
by: dmiller23462 | last post by:
So here's my problem.....I need to set up different email distributions based on which option in the following Select form has been chosen....For instance if "Putaway" is chosen it needs to email...
4
by: Guju | last post by:
Hi all, I wanted sql server to shoot an email upon insert into a table. I treated a trigger on that table as below. CREATE TRIGGER ON . FOR INSERT AS exec sp_sendSMTPmail 'user@user.com',...
14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
2
by: Del | last post by:
I have two question on sending email messages from MS Access (Versio 2000, 2002, and 2003). I have a form with a command button to send an email message, the code behide the button is as follows;...
9
by: Jerim79 | last post by:
I am no PHP programmer. At my current job I made it known that I was no PHP programmer during the interview. Still they have given me a script to write with the understanding that it will take me a...
3
by: YMPN | last post by:
Hi Everyone, I'm deen from Riyadh. Please do help me with some problem i have. I have this formview control setup to recieved inputs from user (textbox, dropdownlist, others). After...
2
by: sindhudixit | last post by:
Hey, I am having a user fill out a form then the fields are going to uploaded to my database. So, at this point, when the user hits the submit button I want three things to happen: 1. The...
9
by: paulmitchell507 | last post by:
I have a file called email2.asp which I am using to mail data obtained from a SQL query. I would like to pass the holiday_ID value in the querystring attached to the end of the URL. It all works...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.