# SQL Code – SOP Document Lock

- URL: https://dynamicaccounting.net/sql-code-sop-document-lock/
- Date: 2007-12-06
- Topics: Sales, Purchasing & Inventory, SQL & Data, Development & Integration
- Type: link to an external article
- Source: http://mbsguru.blogspot.com/

Courtesy of Michael at [MBSGuru](http://mbsguru.blogspot.com/), this script will tell you which users have a Sales Order Processing record locked. In other words, who’s in using sales order processing or who has an orphaned record that is still locking a SOP transaction.

l.row\_id,  
t.dex\_row\_id,  
t.SOPNUMBE,  
a.USERID  
from tempdb.dbo.Dex\_Lock l  
inner join SOP10100 t  
on l.row\_id = t.dex\_row\_id  
inner join DYNAMICS.dbo.Activity a  
on l.session\_id = a.SQLSESID

Michael was kind enough to post this to the Newsgroup in response to a question and he’s letting me share it here with the rest of you. I’ll add it to the script downloads on the right as well.

Update: I had the wrong link for Michael’s site. It’s fixed now. Mea Culpa.
