March 27, 2018 at 1:54 pm
Hi All,
I am doing the following process manually every week, I would like to automate this as much as possible.
I am using Windows 2012 and SQL Server 2012.
1) I invoke a stored procedure which creates a csv file.
2) I open up the csv file and do manual formatting like date columns, sorting by last_date column , etc
Instead I would like the raw csv file to be sent to me by email using Windows Task scheduler or any other process , once I have the file I can continue to refine it and use it,
Please suggest any solutions to this exercise
Thanks in advance
IQ
March 27, 2018 at 2:01 pm
IQ1 - Tuesday, March 27, 2018 1:54 PMHi All,
I am doing the following process manually every week, I would like to automate this as much as possible.
I am using Windows 2012 and SQL Server 2012.
1) I invoke a stored procedure which creates a csv file.
2) I open up the csv file and do manual formatting like date columns, sorting by last_date column , etcInstead I would like the raw csv file to be sent to me by email using Windows Task scheduler or any other process , once I have the file I can continue to refine it and use it,
Please suggest any solutions to this exerciseThanks in advance
IQ
That all could be in a job.
First job step, run the stored procedure.
Second job step, sp_send_dbmail to send the file to you.
Sue
March 27, 2018 at 2:06 pm
Is there any format I should be using when invoking the sp_send_email procedure. Do I need to have the permissions for my user account ?
March 27, 2018 at 2:15 pm
See the documentation:
https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-send-dbmail-transact-sql
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 27, 2018 at 2:18 pm
IQ1 - Tuesday, March 27, 2018 2:06 PMIs there any format I should be using when invoking the sp_send_email procedure. Do I need to have the permissions for my user account ?
Yes you need to provide the appropriate values for sp_send_dbmail and you need permissions to execute the stored procedure as well as the Profile used needs to be available to you. You would need to find out those values as no one here can see how you have database mail setup. The basics of sp_send_dbmail would be: EXEC sp_send_dbmail
@recipients='YourName@domain.com',
@Profile_name = 'Profile you have access to',
@subject='whatever you want for the subject',
@body='whatever you want for the text in the body of the email',
@file_attachments='X:\PathTo\File.csv';
Sue
March 27, 2018 at 4:09 pm
Thanks Sue, I will try this out and let u know how it goes by tomorrow. Thanks for your help
March 27, 2018 at 11:54 pm
IQ1 - Tuesday, March 27, 2018 1:54 PMHi All,
I am doing the following process manually every week, I would like to automate this as much as possible.
I am using Windows 2012 and SQL Server 2012.
1) I invoke a stored procedure which creates a csv file.
2) I open up the csv file and do manual formatting like date columns, sorting by last_date column , etcInstead I would like the raw csv file to be sent to me by email using Windows Task scheduler or any other process , once I have the file I can continue to refine it and use it,
Please suggest any solutions to this exerciseThanks in advance
IQ
You could also modify your proc to do the formatting and sorting for you
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply