What I am looking to avoid concurrency in my stored procedure
here is my script, I am trying SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
ALTER proc [dbo].[SP_GenerateNextReportID]
@type nvarchar(255), @identity int output
AS BEGIN
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
declare @id int;
set @id = IsNull((select LastUsedIdentity from ReportProcessGenerator where Type = @type), 0)
if(@id =0)
insert ReportProcessGenerator values(@type, @id +1)
else
update ReportProcessGenerator set LastUsedIdentity = @id +1 where Type = @type
set @identity = @id +1
END
Not sure is this a right way or not?