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)
 Trigger - 'instead of insert'

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-12-22 : 08:26:10
Graham writes "OS Windows 2000 - Service pack ?
MS SQL 2000 - Service pack ?

Question relates to a client of mine who is hosted on an ASP hence I don't immediately know the service pack level but should be reasonably recent.

I am using (mis using) an "Instead of insert trigger" to fix up an error in our application, because it will take a while to release a software fix to the problem and the client is suffering with the error.

Basically the structure of my trigger is to test for the error condition.

Followed by select all table fields into variables.

Followed by

If error
Insert into table all fields unchanged
else
Insert into table all fields including fixed error field.

The trigger works fine on my own computer.

The trigger fails in the live environment with the application reporting an unknown error 10007 Cannot add duplicate .... (Although I think the text message may be irrelevant). The developers I work with report that they have experienced the same problem with this type of trigger, works OK on some machines but fails on others. Our software uses ADO to talk to the database. (PS although I was a programmer 30 years ago, I now no longer code so excuse my primitive description of the problem).

My questions are - 1). Is there a better way to do what I am trying to do.
2). What could be causing my trigger to fail and what pitfalls are there with instead of insert triggers.

I apologise for not having exact versions etc for software and hope that you can help.

Thanks "
   

- Advertisement -