sql statement fixes for table rename