I have a sql agent job that calls a stored proc which runs a select query. This job takes the results from that select and creates a CSV file which I then email. The problem I have is the resulting file is getting too big to email. I've had to modify my
email attachment size under the management, but that just solves the problem of creating the file. I still need to email it. Is it possible to add a step that will zip the file before emailing it? Here is my code
To email a zipped attachment, you are required to export the result to a location by BCP command first, zip it, and attach it via sp_send_dbmail. For stored procedure to zip a file, please pay attention to this sample:
Zip One File.