Fix issue where if there is no where clause but a limit clause, sql was not adding where rownum but and rownum instead.
casting to int causing exception. Using Convert instead.