Can i lock a record from a join sql statment using ROWLOCK,UPDLOCK ?

Posted by Andrea.Ko on Stack Overflow See other posts from Stack Overflow or by Andrea.Ko
Published on 2010-04-05T07:23:38Z Indexed on 2010/04/05 7:33 UTC
Read the original article Hit count: 341

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about sql

Related posts about rowlocking