Skip to content

Commit 9c0d569

Browse files
authored
Update SQLCMD connect options (#36107)
1 parent 0c7b3f8 commit 9c0d569

5 files changed

Lines changed: 29 additions & 165 deletions

File tree

.openpublishing.redirection.ssms.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6189,6 +6189,11 @@
61896189
"source_path": "docs/ssms/visual-db-tools/work-with-tables-in-database-diagram-visual-database-tools.md",
61906190
"redirect_url": "/ssms/visual-db-tools/work-with-tables-in-database-diagram-visual-database-tools",
61916191
"redirect_document_id": false
6192+
},
6193+
{
6194+
"source_path": "docs/tools/sqlcmd/edit-sqlcmd-scripts-query-editor.md",
6195+
"redirect_url": "/ssms/scripting/sqlcmd-scripts-query-editor",
6196+
"redirect_document_id": false
61926197
}
61936198
]
61946199
}

docs/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8468,7 +8468,7 @@ items:
84688468
- name: Use with scripting variables
84698469
href: tools/sqlcmd/sqlcmd-use-scripting-variables.md
84708470
- name: Edit SQLCMD scripts with Query Editor
8471-
href: tools/sqlcmd/edit-sqlcmd-scripts-query-editor.md
8471+
href: /ssms/scripting/sqlcmd-scripts-query-editor
84728472
- name: Create new local database in a container with sqlcmd
84738473
href: tools/sqlcmd/quickstart-sqlcmd-create-container.md
84748474
- name: SSB Diagnose

docs/tools/sqlcmd/edit-sqlcmd-scripts-query-editor.md

Lines changed: 0 additions & 155 deletions
This file was deleted.

docs/tools/sqlcmd/sqlcmd-commands.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,20 +239,34 @@ The file will be read and executed after a batch terminator is encountered. You
239239

240240
Lists the locally configured servers and the names of the servers broadcasting on the network.
241241

242-
#### :Connect *server_name*[\\*instance_name*] [-l *timeout*] [-U *user_name* [-P *password*]]
242+
#### :Connect *server_name*[\\*instance_name*] [-l *timeout*] [-U *user_name* [-P *password*]] [-N[s|m|o]] [-F hostname_in_certificate]
243243

244244
Connects to an instance of [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)]. Also closes the current connection.
245245

246-
Timeout options:
246+
- Encryption options (`-N[s|m|o]`):
247247

248-
| Value | Behavior |
249-
| --- | --- |
250-
| `0` | Wait forever |
251-
| `n>0` | Wait for *n* seconds |
248+
This option is used by the client to request an encrypted connection. If you don't include `-N`, `-Nm` (for `mandatory`) is the default. This is a breaking change from [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] and earlier versions, where `-No` (for `optional`) is the default.
249+
250+
| Value | Description |
251+
| --- | --- |
252+
| `-Ns` | Strict |
253+
| `-Nm` (default) | Mandatory |
254+
| `-No` | Optional |
255+
256+
- Hostname in certificate (`-F hostname_in_certificate`)
257+
258+
Specifies a different, expected Common Name (CN) or Subject Alternate Name (SAN) in the server certificate to use during server certificate validation. Without this option, certificate validation ensures that the CN or SAN in the certificate matches the server name to which you're connecting. This parameter can be populated when the server name doesn't match the CN or SAN, for example, when using DNS aliases.
259+
260+
- Timeout options:
261+
262+
| Value | Behavior |
263+
| --- | --- |
264+
| `0` | Wait forever |
265+
| `n>0` | Wait for *n* seconds |
252266

253-
The `SQLCMDSERVER` scripting variable reflects the current active connection.
267+
The `SQLCMDSERVER` scripting variable reflects the current active connection.
254268

255-
If *timeout* isn't specified, the value of the `SQLCMDLOGINTIMEOUT` variable is the default.
269+
If *timeout* isn't specified, the value of the `SQLCMDLOGINTIMEOUT` variable is the default.
256270

257271
If only *user_name* is specified (either as an option, or as an environment variable), the user is prompted to enter a password. Users aren't prompted if the `SQLCMDUSER` or `SQLCMDPASSWORD` environment variables are set. If you don't provide options or environment variables, Windows Authentication mode is used to sign in. For example, to connect to an instance, `instance1`, of [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)], `myserver`, by using integrated security you would use the following command:
258272

docs/tools/sqlcmd/sqlcmd-utility.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ monikerRange: ">=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >
4141
The **sqlcmd** utility lets you enter Transact-SQL statements, system procedures, and script files through various modes:
4242

4343
- At the command prompt.
44-
- In **Query Editor** in SQLCMD mode.
44+
- In **Query Editor** in [SQLCMD mode](/ssms/scripting/sqlcmd-scripts-query-editor).
4545
- In a Windows script file.
4646
- In an operating system (`cmd.exe`) job step of a [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] Agent job.
4747

0 commit comments

Comments
 (0)