Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 setting Before/After options in SQL server trigger creation

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-08 : 08:50:49
Murali writes "How can we set Before/After options in SQL Server 7.0 while creating a trigger (in syntax there is no option for that)?"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-08 : 09:06:50
If you mean before and after versions of rows affected by an UPDATE operation, read up on the "inserted" and "deleted" pseudo-tables in Books Online. Look under "triggers", there are numerous examples. Also look in the triggers section on SQL Team:

http://www.sqlteam.com/FilterTopics.asp?TopicID=156

If you are used to triggers in Oracle or some other database product, be aware that SQL Server handles this differently, but you can still do everything that any of the other products can do.

Go to Top of Page

BigRetina
Posting Yak Master

144 Posts

Posted - 2002-07-09 : 04:35:52
If i am reading U correctly , there is no way to specify or guarantee the ORDER of EXECUTION of triggers..
AM I reading U correctly??

Go to Top of Page

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2002-07-09 : 05:01:34
SQL server does not support before triggers, i.e. a trigger that is invoked before an event.

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-09 : 08:49:39
quote:
If i am reading U correctly , there is no way to specify or guarantee the ORDER of EXECUTION of triggers..AM I reading U correctly??

Sure you can, just create one trigger and put all of the commands in the proper sequence of execution. If you have multiple triggers you cannot guarantee their order of execution in SQL Server 7. (SQL 2000 does allow you to set a first and last trigger though)

As I said, read up on SQL Server triggers some more, I guarantee that you can do whatever you need to do with them. If you have more detailed questions please post them, but make sure to include EXACT descriptions of what you want to do, and include the structure of the table(s) involved.
quote:
SQL server does not support before triggers, i.e. a trigger that is invoked before an event.
If you migrate to SQL Server 2000 you can take advantage of INSTEAD OF triggers, which allow you to perform "before" actions.

Go to Top of Page
   

- Advertisement -