Learn more about Toad for SQL Server
at Quest.com

Find solutions and downloads at the
Toad for SQL Server Support Portal

< To bookmark a page, right-click the Page Title and select Add to Favorites / Bookmark This Page

Toad for SQL Server 5.7

You are here: Automate Tasks > Use File Automation Activities

Use File Automation Activities

You can use the following activities in automation scripts.

Tip: You can save an activity and its properties as a template to reuse in other scripts. Right-click the activity in the design window and select Save As Template. After you create the first template, a Templates toolbox displays.

Activity Description

Copy File

Copy or move one or more files to a shared folder where they can be accessed by your business community. You can copy or move a file generated by other activities in the automation script and overwrite an existing copy of a destination file.

Review the following for additional information:

  • Source file—Select a single file to copy, or use an asterisk (*) as a wildcard to select multiple files in the same directory to copy.
  • Copy name—Enter the name. You can use a variable in this field by entering the number sign before and after the variable (#VariableName#).
  • Suffix—Select a suffix to append to the file name. The suffix can be the date and time that the file was generated or the content of a variable that you define with the Set Variable system activity. See Use System Automation Activities for more information.
  • Delete source file—Select (check) to move a file from the source folder to the destination folder. Deselect (uncheck) to copy the file to the destination folder.

Notes:

  • If you want to use this activity for files generated by other automation activities, those activities must precede this one. The filenames and paths specified should match the directories and names displayed in properties for the preceding activities.  

  • You can only use one variable per field or file name (a suffix counts as one variable for a file name).

Delete File

Delete one or more files from a specified location. You can use this activity to delete files that are created earlier in the script.

Note: You can use an asterisk (*) in the FileName field as a wildcard to select multiple files in the same directory to delete.

Log Comment

Writes a comment to the scripts's log.

Zip Files

Create a zip file and add files to it. Files generated with other activities can be added to the zip file. You can then email the zip file to colleagues.

Review the following for additional information:

  • Archive name—Select a location and name for the zip file. You can use a variable in this field by entering the number sign before and after the variable (#VariableName#).
  • Encryption—Select whether to create a zip file without encryption (Standard) or to encrypt the zip file.

    Note: If you encrypt the zip file, you must have a zip utility that can support 128-bit or 256-bit decryption.

  • Zip all files in this directory—Select a directory. All files in the directory will be included in the zip file.
  • Source files—Select one or more files. You can select files that are generated by the automation script.

Notes:

  • If you want to use this activity for files generated by other automation activities, those activities must precede this one. The filenames and paths specified should match the directories and names displayed in properties for the preceding activities.
  • You can only use one variable per field or file name (a suffix counts as one variable for a file name).
Find and Replace

This activity opens one or more files and performs a find and replace within those files. You can write the results to a different location and file name.

Review the following for additional information:

  • Find/Replace—You can have multiple Find/Replace tasks within one activity. You can specify a different set of properties for each Find/Replace task.
  • Source file—Select the file in which to perform the find and replace activity. To select multiple files for one Find/Replace task, use standard wildcard characters in the file name.
  • Find—Enter the content to find.
  • Replace with—Select the type of replacement content: a value, contents from a file, or a variable.
  • Set value—Enter the replacement value, enter the replacement variable, or select a file containing replacement content.

    You can use a variable in this field by entering the number sign before and after the variable (#VariableName#). In the following example, if variable X has a value of 10, the updated file would display "Region 10" instead of "Region".

  • Save file—Select a location and file name.

    Default file is the source file.

  • Suffix—Select a suffix to append to the file name. The suffix can be the date and time that the file was generated or the content of a variable that you define with the Set Variable system activity. See Use System Automation Activities for more information.

Notes:

  • If you want to use this activity for files generated by other automation activities, those activities must precede this one. The filenames and paths specified should match the directories and names displayed in properties for the preceding activities.
  • You can only use one variable per field or file name (a suffix counts as one variable for a file name).
  • Use drag and drop or up/down arrows to change the order of multiple Find/Replace tasks in one activity.

Send Email

Send an email to notify yourself or colleagues about the automation script status. The message automatically includes execution status for each activity that precedes the email activity.

You can also attach files generated by other activities and include a log file or error messages in the email.

Note: To use this activity, an SMTP service must be running.

Review the following for additional information:

  • Enter recipient email address, subject line, and body text.

  • Email Server Settings—Specify SMTP server name and port.

    Default settings are the Email Server Settings specified in Settings properties.

  • Add Attachments—Click to add files created by this script or to browse for other files to add as attachments.
  • Use file for body—Select a file to use as the body of the email. This is useful if you need to send an email to a mobile device that does not support attachments. For example, you could send the results of an Execute Script activity in the body of the email.

    If you use the Toad Report activity, you can select HTML as the output format type. You can then select that HTML file as the body for the email to produce a more professional looking email version of the report.

    You can also customize the file with the Find and Replace activity.

Notes:

  • For the To, CC, Subject, and Body fields: You can use a variable in this field by entering the number sign before and after the variable (#VariableName#).
  • You can only use one variable per field or file name (a suffix counts as one variable for a file name).

FTP File

Upload or download a file using an FTP or SFTP connection. Review the following for additional information:

  • Select an FTP connection—Select an FTP connection or define a new connection.
  • Transfer ONLY if—Select this option to set conditions for FTP transfer, and then select a condition from the list. If you select this option, the FTP activity only runs if the conditions you specify are met. For example, you would select remote file exists if a vendor uploads a file to the FTP site containing a mailing list
  • Local directory—If you selected local directory exists or local file exists, select the local directory to check.
  • Local file—If you selected local file exists, enter the name of the local file.
  • Remote directory—If you selected remote directory exists or remote file exists, select the remote directory to check.
  • Remote file—If you selected remote file exists, enter the name of the remote file.
  • Define Operations—Review the following for additional information:
    • Use file mask—Select this option if you want to match files that use the file mask specified in the File mask field at the bottom of this page.
    • Move files—Select whether to move the files from the source location to the target location when uploading or downloading the files.
Run Automation Script

Run another automation script in your current automation script.

Review the following for additional information:

  • Automation script—Select an automation script (.tas file).
  • Return code—Enter a variable name, such as "RC," for the return code. Return code values are:
    • 0 = Successful execution
    • 999 = An error occurred during execution
    • 111 = An error occurred, but you selected continue on error.

    You can use this variable with the If..Condition activity.

Compare Data

Open a Toad data compare project and export the contents as a PDF, HTML, Excel, CSV, RTF, or MHT file.

  • Project file—Select a Toad data compare project file.
  • Report file—Select a file location, file name, and file type for the export file.
  • Suffix—Select a suffix to append to the file name. The suffix can be the date and time that the file was generated or the content of a variable that you define with the Set Variable system activity. See Use System Automation Activities for more information.

Notes: 

  • Status—Select Enabled to include the activity in script execution. Select Disabled to disable the activity, for example, when testing other activities. Or right-click the activity in the design window and select/deselect Enabled.
  • Stop on Error—Allows you to select, for each activity, whether to stop or continue execution if Toad encounters an error.
  • Select the Log tab to review a script's execution log.
  • Automation does not support positional parameters denoted by a question mark.

 

Related Topics

Automate Tasks

Use Database Automation Activities

Use Variables in Automation

Debbie Peabody's Automation Blog