|
| 1 | +### 🔄 FOREACH Loop Statement |
| 2 | +Iterate through table rows with automatic variable assignment: |
| 3 | +```sql |
| 4 | +FOREACH (@id, @name, @email) IN customers |
| 5 | +BEGIN |
| 6 | + PRINT CONCAT('Customer: ', @name, ' (', @email, ')'); |
| 7 | +END |
| 8 | +``` |
| 9 | +- Variables are automatically declared and assigned values from each row |
| 10 | +- Supports BREAK and CONTINUE statements like other loops |
| 11 | +- Works with tables, views, and subqueries |
| 12 | + |
| 13 | +### 💻 Command-Line Interface |
| 14 | +Execute SQL Notebook scripts from the command line without opening the GUI: |
| 15 | +```bash |
| 16 | +SqlNotebookCmd "MyNotebook.sqlnb" "MyScript" |
| 17 | +``` |
| 18 | +- Perfect for automation, batch processing, and CI/CD pipelines |
| 19 | +- Outputs results in CSV format |
| 20 | +- Returns appropriate exit codes for success/failure |
| 21 | + |
| 22 | +### 📝 Dynamic Script Management |
| 23 | +Create and delete scripts programmatically: |
| 24 | +```sql |
| 25 | +-- Create a new script |
| 26 | +CREATE SCRIPT DataCleanup AS ' |
| 27 | + DELETE FROM temp_table WHERE processed = 1; |
| 28 | + PRINT ''Cleanup completed''; |
| 29 | +'; |
| 30 | + |
| 31 | +-- Execute the script |
| 32 | +EXECUTE DataCleanup; |
| 33 | + |
| 34 | +-- Remove the script when no longer needed |
| 35 | +DROP SCRIPT DataCleanup; |
| 36 | +``` |
| 37 | +- `CREATE SCRIPT` to add new scripts dynamically |
| 38 | +- `DROP SCRIPT` and `DROP PAGE` to remove scripts and pages |
| 39 | +- Useful for generating reports, temporary procedures, and workflow automation |
| 40 | + |
| 41 | +### 💾 Save Command |
| 42 | +Save your notebook programmatically from within scripts: |
| 43 | +```sql |
| 44 | +-- Save to current file |
| 45 | +SAVE; |
| 46 | + |
| 47 | +-- Save to a specific file |
| 48 | +SAVE 'MyBackup.sqlnb'; |
| 49 | +``` |
| 50 | +- Particularly useful in SqlNotebookCmd for persisting changes |
| 51 | +- Must be used outside of transactions (use "None (auto-commit)" mode in GUI) |
| 52 | + |
| 53 | +### 🦆 DuckDB Integration |
| 54 | +Import data from DuckDB files with full UI support: |
| 55 | +- Drag and drop `.duckdb` files directly into SQL Notebook |
| 56 | +- Available in Import menu → "From file..." |
| 57 | +- Support for both copying data and live database connections |
| 58 | +```sql |
| 59 | +-- Copy data from DuckDB |
| 60 | +IMPORT DATABASE 'duckdb' |
| 61 | +CONNECTION 'Data Source=C:\data\analytics.duckdb' |
| 62 | +TABLE sales_data; |
| 63 | + |
| 64 | +-- Create live connection |
| 65 | +IMPORT DATABASE 'duckdb' |
| 66 | +CONNECTION 'Data Source=C:\data\analytics.duckdb' |
| 67 | +TABLE sales_data |
| 68 | +OPTIONS (LINK: 1); |
| 69 | +``` |
| 70 | + |
| 71 | +### 🗄️ Enhanced SQLite Support |
| 72 | +Expanded SQLite file compatibility: |
| 73 | +- Open SQLite databases (`.db`, `.sqlite`, `.sqlite3`) directly via File → Open |
| 74 | +- Import SQLite tables using the same interface as other databases |
| 75 | +- Seamless integration with your existing SQLite workflows |
0 commit comments