You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Executes a batch of management commands in the scope of a single database.
13
13
14
14
> [!NOTE]
15
-
> Select the full command text before running it. Otherwise, it will stop at the first empty line in the script.
15
+
> Select the full command text before running it. Otherwise, it stops at the first empty line in the script.
16
+
17
+
> [!TIP]
18
+
> By default, the `.execute database script` command always succeeds. If you want the command to fail when one of the commands in the script fails, run the command with the `ThrowOnErrors` property set to `True`. For example: `.execute database script with (ThrowOnErrors=true)`.
16
19
17
20
## Permissions
18
21
@@ -24,7 +27,7 @@ You must have at least [Database Admin](../access-control/role-based-access-cont
@@ -53,10 +56,10 @@ Each command appearing in the script is reported as a separate record in the out
53
56
54
57
>[!NOTE]
55
58
>
56
-
>* The script text may include empty lines and comments between the commands.
59
+
>* The script text can include empty lines and comments between the commands.
57
60
>* Commands are executed sequentially, in the order they appear in the input script.
58
-
>* Script execution is sequential, but non-transactional, and no rollback is performed upon error. It's advised to use the idempotent form of commands when using `.execute database script`.
59
-
>* Execution of the command requires Database Admin permissions, in addition to permissions that may be required by each specific command.
61
+
>* Script execution is sequential, but non-transactional, and no rollback is performed upon error. We recommend that you use the idempotent form of commands when using `.execute database script`.
62
+
>* Execution of the command requires Database Admin permissions, in addition to the permissions required by each specific command.
60
63
>* Default behavior of the command - fail on the first error, it can be changed using property argument.
61
64
>* Read-only management commands (`.show` commands) aren't executed and are reported with status `Skipped`.
62
65
@@ -96,6 +99,6 @@ The following example executes a script with multiple operations, continuing to
|67d0ea69-baa4-419a-93d3-234c03834360|RetentionPolicyAlter|.alter-merge table T policy retention softdelete = 10d|Completed||
101
-
|0b0e8769-d4e8-4ff9-adae-071e52a650c7|FunctionCreateOrAlter|.create-or-alter function with (skipvalidation = "true")SampleT1(myLimit: long) {T1 \| take myLimit}|Completed||
|67d0ea69-baa4-419a-93d3-234c03834360|RetentionPolicyAlter|`.alter-merge table T policy retention softdelete = 10d`|Completed||
104
+
|0b0e8769-d4e8-4ff9-adae-071e52a650c7|FunctionCreateOrAlter|`.create-or-alter function with (skipvalidation = "true")SampleT1(myLimit: long) {T1 \| take myLimit}`|Completed||
0 commit comments