Problem solve Get help with specific problems with your technologies, process and projects.

Problem deleting records on table with trigger to delete other records

I'm not a DBA, just an ASP developer. I have a table, aUser, with a trigger called DelUser that forces a delete from several other tables when deleting a record from aUser. I need to delete record from aUser where the userid is NOT in another table ("indExport"). The table "Webuser" is one of the tables in the trigger. My SQL is:
 select count(userid) from Webuser where not exists (select * from aUser where Webuser.userid = aUser.userid AND aUser.remoteid = indExport.inum).
The query goes on forever, and after 30 minutes, I cancelled it. Question: should I delete records in the trigger-referenced tables before I delete them from aUser? I'm at a total loss here.

In general, yes, that is the best practice. As for the query you are running, you said it goes on forever. What part of it goes on forever? Why does it go on forever? How are the tables indexed? And to top that off, you have created a query with a cross product in it which is going to kill your SQL Server. You are creating a three way cross product to be exact between aUser, Webuser, and indExport.


For More Information

Dig Deeper on Microsoft SQL Server Installation

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.