Error fix for empty database in query agent, another error in SQL file