prepares sql for delivery