In this tutorial, you will build a script that uses the Execute Script activity to run a small SQL script prior to executing other database activities.
In this tutorial you will learn:
You will need:
An Import Wizard template (configured to import a table into the sample database)
Note: For a tutorial on how to create an Import Wizard template, see Automation and Importing Data.
Watch Automation and Executing Scripts to see a video presentation of this tutorial.
The most common Automation tasks involve importing and exporting data. You may find, however, that sometimes these tasks also require some database setup. Database setup can be accomplished by adding the Execute Script activity to your Automation script. The Execute Script activity can be used to execute simple or complex scripts.
In this example, you will use the Execute Script activity to "clean up" a database by dropping and then recreating it prior to importing data.
For this tutorial, you will want to use a sample database or a sandbox area.
In the Activity Input tab, click to browse to and select your Import Wizard template to import data into the sample database.
Note: To learn how to use the Import Wizard activity, see the Automation and Importing Data tutorial.
If you have a situation where the SQL script in your Execute Script activity errors, but you would like the Automation script to continue, you can configure the script to continue after an error. For example, if the database doesn't exist, the script will error, but you would want the script to continue in this situation.
Select the Activity Info tab for the Execute Script activity, and deselect the Stop on Error option. This instructs the Automation script to continue even if this activity (and only this activity) errors.
The Execute Script activity can be used to execute simple to complex scripts. It is a simple activity, but can be useful in many ways.
See Schedule Your Script to learn how to schedule the Automation script.