CREATE SCRIPT
Statement
Creates a script in the notebook.
Syntax
CREATE SCRIPT script-name AS sql-commands;
Parameters
- script-name: text
The name of the script to create. This can be a string literal or an expression that evaluates to a string. - sql-commands: text
The SQL commands that will comprise the script body. This can be a string literal or an expression that evaluates to a string.
Remarks
The CREATE SCRIPT statement creates a new script in the notebook with the specified name and content. Script names are case-insensitive.
If a script with the specified name already exists, an error is thrown.
Once created, the script can be executed using the EXECUTE statement.
Examples
CREATE SCRIPT MyScript AS 'PRINT ''Hello World'';';
Creates a script named "MyScript" that prints "Hello World".CREATE SCRIPT ReportScript AS 'SELECT * FROM users WHERE active = 1;';
Creates a script named "ReportScript" that queries active users.CREATE SCRIPT ('Report' || '2024') AS 'PRINT ''Report for 2024'';';
Creates a script whose name is the result of concatenating "Report" and "2024", i.e., "Report2024".