Change
set @intNew = cast(substring(@strSuffix1,0,5) as int) + 1
to
set @intNew = cast(substring(@strSuffix1,1,5) as int) + 1
OR even rather use
LEFT(@strSuffix1,5)
rather than
substring(@strSuffix1,1,5)
so, something like
set @intNew = cast(LEFT(@strSuffix1,5) as int) + 1
start
Is an integer or bigint expression that specifies where the returned characters start. If start is less than 1, the returned expression will begin at the first character that is specified in expression. In this case, the number of characters that are returned is the largest value of either the sum of start + length- 1 or 0. If start is greater than the number of characters in the value expression, a zero-length expression is returned.
So that would imply start + length- 1 = 0 + 5 - 1 = 4
, which would imply cast(substring(@strSuffix1,0,5) as int)
is 0, and set @intNew = cast(substring(@strSuffix1,0,5) as int) + 1
= 1