create procedure [dbo].[get_next_id] @id_entry int, @in_trans smallint as     declare @next int     IF @in_trans = 0        begin transaction     update AtSystemparameter Set paramvalue=convert(char(32), convert(int, paramvalue)+1) where paramid = @id_entry     select @next=(select convert(int,paramvalue) from AtSystemparameter where paramid = @id_entry)     IF @next = 2147483647     BEGIN        update AtSystemparameter Set paramvalue=0 where paramid=@id_entry     END     select paramvalue from AtSystemparameter where paramid =@id_entry     IF @in_trans = 0        commit transaction     return 1  