all groups > sql server new users > april 2006 >
You're in the

sql server new users

group:

trigger is not fired



trigger is not fired sachin bhayana
4/26/2006 12:00:00 AM
sql server new users: I have attatched a trigger with the insertion of a table but when i insert
into the table the trigger is not fired.

Re: trigger is not fired Andrew Watt [MVP]
4/26/2006 12:00:00 AM
On Wed, 26 Apr 2006 14:27:00 +0530, "sachin bhayana"
[quoted text, click to view]

Hi,

Some additional information would be useful.

For example are you using SQL Server 2000 or SQL Server 2005? Can you
show us the code for your trigger?

Thanks

Re: trigger is not fired shoeb ali
4/26/2006 12:00:00 AM
actually i have developed an application which converts XML data recieved
through email into database format and stores it into database
automatically without any human intervention.
When Insertion is automatic trigger does not fire but i need it to be
fired.
when i manually insert record in the table the trigger fires.

how can i have the trigger fired in case of automatic insertion

the code of trigger is as follows:

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


CREATE TRIGGER [trig_addIncident] ON dbo.Incident
FOR INSERT
AS


DECLARE @newBug VARCHAR(100)
SELECT @newBug=(SELECT IncidentID + ' ' Subject FROM Inserted)

--print the detail of new Incident

PRINT 'New Incident " ' + @newBug + ' " added. '


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO



[quoted text, click to view]

Re: trigger is not fired Jens
4/26/2006 7:30:43 AM
Triggers are fired on a statement NOT on a row basis, so you have to
handle your inserted data as there were always more than just one row.

So try to fix that and come back if the problem still exists.

HTH, Jens Suessmeyer.

---
http://www.sqlserver2005.de
---
Re: trigger is not fired Hugo Kornelis
4/26/2006 10:45:32 PM
[quoted text, click to view]

Hi shoeb ali,

Jens' remark about changing the trigger to handle multi-row inserts is
absolutely right. But I have another question.

The main action in your trigger appears to be:

[quoted text, click to view]

Are you aware that the result of a PRINT statement in a trigger is sent
back to the client that performs the operation that fired the trigger?
In your case, the application that automatically inserts the row in the
database will be on the receiving end of the PRINT statement - if that
application doesn't handle the text returned by SQL Server, it will be
lost.

--
AddThis Social Bookmark Button