script to produce a nightly sql report