Fix minor insert bug when @maxnum is null