Last post Aug 19, 2018 12:23 PM by mgebhard
Aug 18, 2018 07:08 PM|dev_dona|LINK
create procedure test
declare @lastval varchar(10)
set @lastval = right('000000000' + convert(varchar(10),(select IsNull(max(Serialno),0)+1 from MyTable)),10)
if i generate serial no following above approach then does it create race condition ?
because from multiple session the above SP will be access may at same time and try to generate serial no which will be inserted in table as PK value. so is there any chance to generate same serial no for two session....if yes then how to avoid it just guide
Aug 19, 2018 12:23 PM|mgebhard|LINK
Yes, you must worry about concurrency.
I've already explained how to do this without worrying about possible conflicts using a standard Identity column in SQL Why are you making such a simple process so complicated?