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 2005 Forums
 Transact-SQL (2005)
 INSERT TRIGGER

Author  Topic 

sqldba20
Posting Yak Master

183 Posts

Posted - 2007-12-04 : 11:00:55
Can I have 2 or MORE INSERT TRIGGERS on the SAME TABLE?


Thanks !

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-04 : 11:13:59
What happens when you try to create two insert triggers?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sqldba20
Posting Yak Master

183 Posts

Posted - 2007-12-04 : 11:29:52
Well.. I never tried and I don't want to in Production and I don't have any DEV or TEST servers. I just want to know whether we can do it.
Go to Top of Page

cr8nk
Yak Posting Veteran

77 Posts

Posted - 2007-12-04 : 18:27:02
Yes, you can. Be sure to set the order if you have more than one.


use tempdb

go

create table dbo.MultipleTriggerTest
(
Id int,
Col1 varchar(10)
)

go

CREATE TRIGGER trTriggerTestI1 ON dbo.MultipleTriggerTest
AFTER INSERT

AS

select 'first insert trigger'

go

CREATE TRIGGER trTriggerTestI2 ON dbo.MultipleTriggerTest
AFTER INSERT

AS

select 'second insert trigger'

go

sp_settriggerorder @triggername= 'dbo.trTriggerTestI1', @order='First', @stmttype = 'INSERT'

INSERT INTO dbo.MultipleTriggerTest(Id, Col1) VALUES (1,'ROW 1')
INSERT INTO dbo.MultipleTriggerTest(Id, Col1) VALUES (1,'ROW 2')



At the very least you need a development server where you can test code out. You don't want to implement changes on production without testing somewhere.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-12-04 : 18:56:58
quote:
Originally posted by sqldba20

Well.. I never tried and I don't want to in Production and I don't have any DEV or TEST servers. I just want to know whether we can do it.



I'd remove dba from my userid if I had an environment like that.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -