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
 Transact-SQL (2000)
 how does a trigger execute ?

Author  Topic 

sandy_27_1111
Starting Member

1 Post

Posted - 2003-01-14 : 06:16:01
I have a insert trigger for a table "a"
I wanted to know was when will the trigger gets executed ?
after the insert statement has been executed or before the insert statement being executed

for e.g
create trigger t_a on <table name> for insert as
select * from <table_name>

(will this give me the list off all the rows of the table including the row that will be inserted ?)

nr
SQLTeam MVY

12543 Posts

Posted - 2003-01-14 : 06:38:18
This will be executed after the insert.
An insead of trigger will be executed instead of the insert.

This will give the inserted rows.

Had you thought of testing it to find out what happens?
create table a (i int)
create trigger x on a for insert
as
select * from a
go
insert a select 1
insert a select 2


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -