SQL Server UPDATE WITH ROWLOCK Doesn't seem to be working -


i have scenario whereby need retrieve int database table, increment 1 return old value. need ensure if stored procedure called again returned value (nextbookingid) not identical value returned first call of stored prodcedure.

i've been using code below , assumed working don't think it's been tested until , appears not working, 2 seperate , immediate calls of stored procedure appear returning same value.

declare @nextbookingid int  update company (rowlock) set  @nextbookingid = (nextbookingid),      nextbookingid = (nextbookingid + 1) companyid = @companyid   select      companyid ,   @nextbookingid nextbookingid company companyid = @companyid 

should wrapped in transaction? have clustered index on companyid primary key.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -