Current position:  Home > Default > Truncate table lock issue

Truncate table lock issue

Time:November 30
    In my SQL2000 stored procedure, there are 9 truncate table commands.
     But the the stored procedure is take above 15 minutes to execute.
     In this stored procedure, truncate table command has no problem.
     But an insert query into that table is very slow.
     In the insert query, select some views output and insert into the table. But these select output is very slow.
     I search some forums. They said that lock problem for the object. Query execution delayed for a exclusively accessed object.
    How can I remove the lock for my strored procedure running faster ? 
Here are the bad news: you need to have some understanding of indexing to get some results out of it. But since we don't know anything about your queries, we cannot really give much better advice. What we can say is that TRUNACTE TABLE has nothing to
do with it. Probably not locking either. Locking would come from concurrent activity in the database. Is there any?
Normally, we ask people to submit the code they have problem with. In this case we would also need see the view definitions. (Else we would still be in the dark.) And if the views are built on views, we need to see these as well. This may result in more
code that is practic to handle here, but I leave that up to you. As a hint: in the next step we are much likely to ask for the table and index definitions.
Erland Sommarskog, SQL Server MVP, [email protected]