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)
 Error "The DROP TABLE statement is not allowed within a trigger"

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-06-02 : 07:16:09
Emmie writes "I have a trigger that calls a stored procedure. Within the stored procedure the very last last line is a DROP TABLE statement. The DROP TABLE statement is always executed when the stored procedure is invoked, and the temp table that it is trying to drop always exists. This process (ie. calling a stored prcedure from a trigger) works 90% of the time but sometimes crashes with the following SQL Server error message:

"The DROP TABLE statement is not allowed within a trigger."

Has anyone ever encountered this error?

I am using SQL Server 7.0."

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-06-02 : 09:33:32
Triggers don't execute 1 per record inserted/deleted/updated. They execute once per invokation of the command....regardless of the number of records deleted/insert/updated by the command.


What sort of table are you deleting...if it's a temporary table...then you have no need to clean-up after the SP....it dies at the end of the SP anyway.


The process works 90% of the time....because I suspect you have some conditional logic that 90% of the time skips the DROP TABLE command....

I think you will have to rethink what you are doing.


POST the sample trigger + SP...and you may get a resolution....leave out any company-confidential information.
Go to Top of Page
   

- Advertisement -