Atgscripts

Made changes in the scripts to handle errors in data and SQL script.