Can i lock a record from a join sql statment using ROWLOCK,UPDLOCK ?
- by Andrea.Ko
I have a store procedure to get the data i want:
SELECT a.SONum, a.Seq1, a.SptNum, a.Qty1, a.SalUniPriP, a.PayNum, a.InvNum,
a.BLNum, c.ETD, c.ShpNum, f.IssBan
FROM OrdD a JOIN OrdH b ON a.SONum = b.SONum
LEFT JOIN Invh c ON a.InvNum = c.InvNum
LEFT JOIN cus d ON b.CusCod = d.CusCod
LEFT JOIN BL e ON a.BLNum = e.BLNum
LEFT JOIN PayMasH f ON f.PayNum = a.PayNum
LEFT JOIN Shipment g ON g.ShpNum = c.ShpNum
WHERE b.CusCod IN (SELECT CusCod FROM UsrInc WHERE UseID=@UserID and UseLev=@UserLvl) AND d.CusGrp = @CusGrp
After i get those records into cursor, i used RowLock, UpdLock to lock all the related invoice number.
SELECT InvNum FROM Invh WITH (ROWLOCK,UPDLOCK) WHERE InvNum =
Can i issue locking on the table INVH at the point i select the table from a few table using join command?
Any advice, please!