Automation

Hello ,

I need to execute script and send result by mail

from automation tab, i drag execute scirpt and paste the script

after that i drag send mail and configure mail server setting

but i didn’t find from where I define that he mail will contain the script outlook?

Also I need to know when i use LINK SQL file ? i didn’t understand the benfit from it

Thanks

Hi,

You can use "Select to File" instead of "Execute Script".

Then click "Add attachment" to select the result file, or setting the result file in "Use file for body".

When check the Link SQL file checkbox, this means that toad will execute script from file. You can select file as below.

For more Send Email details, please refer the help document.

Open the Help doc : Help ->Toad Help

Path: Automate Tasks | Tutorials | Automate Sending Email

If you have more questions, please feel free to contact us.

Regards,

Kelly

Hi Kelly

Please see the attached image for Select to File in my automation window. I am using Toad for SQL Server Expert Edition V 6.5. Nowhere I'm seeing the option to attach. I'm looking to execute a script which has bunch of sql statements and have the results of all statements logged to a file. All statements are just select statements.

Let me know your thoughts.

Thanks

Prashant

Hi Prashant,

Did this button what you want?

Michael

Hi Michael,

That button is to select a sql file that needs to be executed.I am looking for sending the output of query to a file as the example in one of the automation thread shows. For me, the Select to File and Execute Script both look same with only difference where Select to File has option for export to 3 types of files. I tried that but only dumps one line of output where I’m expecting a quite a lot as my script has ton of select statements for which I’m looking for output (something like Oracle SQL command line where you can direct output of sql to a file)

I think I finally found why my script output wasn’t sent to excel file. What I see that if my script has more than one sql statements, it only outputs the first one to the excel. In my case, I was looking for some count to perform an action so it created that one line output in excel which was bit non-intuitive to figure out what’s going on. When I tried other simple SQL statements, it worked perfectly but as soon as I add another statement, it ignored everything after first one. Hope this helps to recreate problem at your end and a solution

Hi Michael:

I was wondering if you or anyone got chance to look at this problem. Solution to this would really help many users to create output reports from multiple sql statements.

You will need to break your script into multiple export outputs. If you want them all to be in the same file, have them export to the same file (making sure that the overwrite option is unchecked in any subsequent exports after the first one). You can even name the tabs. Hope this helps.

Thank you so much. This worked well although added a quite a lot of work to split into and then wire up a ton of sql files. Now that I’m able to do this, I was wondering if there is any option to loop through a folder and run scripts?

Well. SQL rules still apply so you would have to write a C-based code section that loops through an external file system provided the SQL server and your file location “know” each other. Very, Very difficult and WAY above my pay grade. I wish I could help my friend but I’m just not that good. Perhaps someone on the boards could share some coding for both of us because that would be very interesting.