Updated sql in order to run on server