SQL adjustments for batch download