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)
 Trigger problem

Author  Topic 

FabioEinaus
Starting Member

41 Posts

Posted - 2006-12-19 : 09:38:17
Hi ppl!

I have 2 triggers in a table (ProjectosTrabalhos) and on those 2 I made a INSERT INTO to do an Audit table.

I have a Instead of INSERT with this:

INSERT INTO Audit SELECT GetDate(), I.UserIDCreated, 'ProjectosTrabalhos', I.UserIDCreated+'introduziu novo trabalho na obra '+CONVERT(varchar,I.ProjectID)+'com o Técnico '+ CONVERT(varchar,I.Tecnico)+' com '+CONVERT(varchar,I.Horas)+' horas e a seguinte descrição: '+CONVERT(varchar,I.Descricao) FROM Inserted I

And I have a Instead of UPDATE with this:

INSERT INTO Audit SELECT GetDate(), I.UserIDCreated, 'ProjectosTrabalhos', (I.UserIDCreated+'modificou trabalho com sequencial '+CONVERT(varchar,I.Sequencial)+' para: obra '+CONVERT(varchar,I.ProjectID)+'com o Técnico '+ CONVERT(varchar,I.Tecnico)+' com '+CONVERT(varchar,I.Horas)+' horas e a seguinte descrição: '+CONVERT(varchar,I.Descricao)) FROM Inserted I


The problem is, if I remove the line on the Instead of INSERT the update works fine and vice-versa, but, if I have both working it inserts 1 of the insert and 8 rows of the update...

I just don't understand why it do that...

Thanks in advance for the replys


harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-19 : 10:24:35
What is the status of Nested Triggers option for your database server? Also check if Recursive Triggers option is on for the database.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

FabioEinaus
Starting Member

41 Posts

Posted - 2006-12-19 : 11:32:46
Yes I have that option as True but I changed that and it didn't solve the problem :(

Go to Top of Page
   

- Advertisement -