Updated SQL code to account for database config differences.
Version to 8.1.1