Getting Started
From Scripts (accessed via Code in the top Navigation menu), click on New Script in the top-right corner of the page and select SQL.
Setting Up the Script
- Click the script title to rename your script.
- Put your SQL code into the code box in the center of the page. If your script ends with a SELECT statement, it can be used to power a Report or generate an Export. See the respective help documentation for more information on those functions.
- Once your SQL is ready, click the Run Now button in the top-right corner of the page.
Multiple Statements
You can separate multiple SQL statements using semicolons. When multiple statements are provided, they are run in a single transaction. For most scripts, this means that an error anywhere in the script causes the whole query to have no effect. To avoid this behavior, you can use BEGIN
and COMMIT
SQL commands within your query (see this article for more information). However, we recommend using Workflows instead if your use case requires large, complex SQL scripts.
Customizing the Success Notification
You can customize the body of the success notification email in the notifications pane. If your SQL Script generates a file, you can link to it by putting "[link to file] ({{file_url}})"
in the body section. This link will expire after 36 hours.
Scheduling Your Script
If you'd like to set your script to run on a schedule, click on the clock icon in the top-right corner of the page. From there you can have the export run on a schedule of your choosing, or else incorporate it into a workflow. For more information about job automation, see the Automate and Workflow help documentation.
Cancel Your Script
If you find your script is incorrect or running longer than expected, open the script's Run Log and click the 'x' button next to the spinner to cancel the script.
Cached Results
SQL Scripts take advantage of export caching to improve performance and reduce the load on your Platform data warehouse. Please see Export Caching for more information.
Comments
0 comments
Please sign in to leave a comment.