if u understood what si_the_geek said. Create a stored Procedure to do insert/ Update Operation in your database

In that Sp when No value/0 is supplied to BookId parameter find the Next Id and perform insert.
Code:
Select @BookId=isnull(max(BookId),0)+1 from <YourTableName>