Creating a Task to Run a SQL Script

Running SQL scripts based on a schedule is the most powerful and useful feature of the Task Scheduler.

Perform the following steps to create a task to run an SQL script:

1          Start WinSQL Professional and connect to the desired database.

2          Create a query and save it with an .SQL extension.

For more information, see “Writing SQL Scripts.”

3          From the Tools menu, click Scheduler. The following window displays:

4          Double-click Add New Task in the Existing tasks pane, OR click Add Task. The following window displays:

5          Use the following information to specify the desired parameters:

Field

Description

Task Name

Name for this task

Task Type

Type of task to run

Email Status

Select an option from the drop down menu for the type of e-mail status message you wish to receive.

Note: If you elect to send a status email, you must configure the outbound e-mail parameters by clicking Configure email server ().

For more information, see “Configuring the email server.”

Attach output file in email

Click to select this option if you want to attach the output file in the status e-mail.

Inherit global settings for email recipients

Select this option to deliver a task status e-mail to all recipients that have been globally configured in WinSQL

OR

Clear this check box to send a task status e-mail to a select group of recipients. If this option is selected, a window displays that allows you to enter specific e-mail addresses.

Terminate WinSQL Professional once task is completed

Click to select if you want WinSQL Professional to terminate once the task has run.

Script file name

Name of the script file created and saved in step 2.

Output file name

The name of the file that contains the results (and any warnings or error messages) of the script.

Configuring the email server

1          Click the Configure email server () icon to the right of the Email Status field. The following window displays:

2          Complete the fields on the Email Server section of this window, and then click OK to close the window and return to the Schedule Task Editor window, where the newly-created task displays in the Existing tasks pane.

Note: SMTP server host and Email recipient are required fields. All others are optional.

If you are unsure how to complete these fields, contact your information technology (IT) department.

3          Ensure the desired task is selected, and then click Modify Schedule to assign a schedule to the task.

Important note: WinSQL Professional is tightly integrated with the Windows operating system for task scheduling. Therefore, your login ID must have sufficient rights to run the desired task.

4          Click the Task, Schedule, and Settings tab to assign the desired options to the task.

Notes:

·Consult the Windows operating system documentation or online help for further information about scheduling tasks.

·Confirm the system date and time are correct on your computer. Scheduled tasks rely on this information to execute tasks on a specified date and at a specified time.