The query you posted gives a syntax error... but I see what you are trying to do.
The reason is is returning 2 is because you are looking for the MAX of a string, not a number. Try something like this:-
select max(convert(int,substring(bookid,3,8))) from tablename