471,108 Members | 1,301 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

What type of TRIGGER to use?

MAS
Is there a type of TRIGGER that I can use to do do post-INSERT
processing? I've got one table that I never want to block the INSERT,
but instead need to do post INSERT processing on. The only way I know
to do this is via a JOB, which isn't ideal in this scenerio.

mas
Jul 20 '05 #1
5 6935
Mas,

Check the Books Online and look for CREATE TRIGGER. You can specify whether
a trigger fires before or after an action. (Or even insted of it, so you can
override the action)
Example:

create trigger TriggerName
on YourTable
after insert
as
<TriggerBody>

Good luck,
Shervin

"MAS" <di***********@yahoo.com> wrote in message
news:47**************************@posting.google.c om...
Is there a type of TRIGGER that I can use to do do post-INSERT
processing? I've got one table that I never want to block the INSERT,
but instead need to do post INSERT processing on. The only way I know
to do this is via a JOB, which isn't ideal in this scenerio.

mas

Jul 20 '05 #2
Shervin Shapourian (Sh**********@hotmail.com) writes:
Check the Books Online and look for CREATE TRIGGER. You can specify
whether a trigger fires before or after an action. (Or even insted of
it, so you can override the action)


To be more precise, you have the choices of AFTER and INSTEAD OF. There
is no BEFORE trigger. If you go for INSTEAD OF, you need handle the
insert/update/delete operation yourself.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3
Erland,

I thought FOR is used for BEFORE triggers, but I was wrong. Thanks for the
correction. This is what I like about newsgroups, you always learn new
things, especially when you get envolved in problem solving.

Thanks again,
Shervin
"Erland Sommarskog" <so****@algonet.se> wrote in message
news:Xn*********************@127.0.0.1...
Shervin Shapourian (Sh**********@hotmail.com) writes:
Check the Books Online and look for CREATE TRIGGER. You can specify
whether a trigger fires before or after an action. (Or even insted of
it, so you can override the action)


To be more precise, you have the choices of AFTER and INSTEAD OF. There
is no BEFORE trigger. If you go for INSTEAD OF, you need handle the
insert/update/delete operation yourself.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Jul 20 '05 #4
MAS
Thanks Shervin. The AFTER INSERT trigger worked.
Jul 20 '05 #5
Shervin Shapourian wrote:
Erland,

I thought FOR is used for BEFORE triggers, but I was wrong. Thanks for the
correction. This is what I like about newsgroups, you always learn new
things, especially when you get envolved in problem solving.

Thanks again,
Shervin
"Erland Sommarskog" <so****@algonet.se> wrote in message
news:Xn*********************@127.0.0.1...

Shervin Shapourian (Sh**********@hotmail.com) writes:

Check the Books Online and look for CREATE TRIGGER. You can specify
whether a trigger fires before or after an action. (Or even insted of
it, so you can override the action)

To be more precise, you have the choices of AFTER and INSTEAD OF. There
is no BEFORE trigger. If you go for INSTEAD OF, you need handle the
insert/update/delete operation yourself.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Correct. If you want BEFORE triggers you need to use Oracle, DB2, or
Informix.

--
Daniel Morgan
http://www.outreach.washington.edu/e...ad/oad_crs.asp
http://www.outreach.washington.edu/e...oa/aoa_crs.asp
da******@x.washington.edu
(replace 'x' with a 'u' to reply)

Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by signaturefactory | last post: by
7 posts views Thread by Shane | last post: by

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.