We have a proc that runs Truncate Table
inside an Snapshot transaction. This seems to be causing a LOCK_M_S
lock that blocks the sys view sys.partitions
.
Is there a convenient work around for this? I like the efficiency of not taking excess logs that happens with truncate, but don't want to lock up my sys.partitions
.
I'm happy to post the code upon request, but I'm pretty sure this is some behavior of Truncate
being inside a Snapshot transaction. that i'm just unaware of.
sys.partitions
from being accessed, then I don't think that the problem is the truncate - aDELETE * FROM
should have the same effect. The problem is that it is inside a transaction, and that the pending actions on the table are blocking thesys.partitions
view... somehow. As a question, have you tried the statementSELECT * FROM sys.partitions WITH(NOLOCK)
sys.partitions
view can lock/block, but it depends on what columns are selected. Try limiting the columns selected from the view, and see if that works.