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
Copy file name to clipboardExpand all lines: README.md
+37-15
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# SQLCMD CLI - Preview
1
+
# SQLCMD CLI
2
2
3
3
This repo contains the `sqlcmd` command line tool and go packages for working with Microsoft SQL Server, Azure SQL Database, and Azure Synapse.
4
4
@@ -8,13 +8,22 @@ This repo contains the `sqlcmd` command line tool and go packages for working wi
8
8
9
9
### Windows
10
10
11
-
`sqlcmd` is available via [Winget][], and as a downloadable .msi or .zip from the [releases page][]. The .msi installer is signed with a Microsoft Authenticode certificate.
11
+
`sqlcmd` is available via [Winget][], [Choco][]and as a downloadable .msi or .zip from the [releases page][]. The .msi installer is signed with a Microsoft Authenticode certificate.
To connect to the current context, and use the original ODBC sqlcmd flags (e.g. -q, -Q, -i, -o etc.), that can be listed with `sqlcmd -?`, run:
100
+
To connect to the current context, and use the original ODBC sqlcmd flags (e.g. -q, -Q, -i, -o etc.), which can be listed with `sqlcmd -?`, run:
92
101
93
102
```
94
103
sqlcmd -q "SELECT @@version"
95
104
sqlcmd
96
105
```
97
106
98
-
If no current context exists, `sqlcmd` (with no connection parameters) reverts to the original ODBC `sqlcmd` behavior of connecting to the default local instance on port 1433 using trusted authentication.
107
+
If no current context exists, `sqlcmd` (with no connection parameters) reverts to the original ODBC `sqlcmd` behavior of creating an interactive session to the default local instance on port 1433 using trusted authentication, otherwise it will create an interactive session to the current context.
99
108
100
109
## Sqlcmd
101
110
@@ -123,10 +132,20 @@ The following switches have different behavior in this version of `sqlcmd` compa
123
132
- All commands must fit on one line, even `EXIT`. Interactive mode will not check for open parentheses or quotes for commands and prompt for successive lines. The ODBC sqlcmd allows the query run by `EXIT(query)` to span multiple lines.
124
133
-`-i` now requires multiple arguments for the switch to be separated by `,`.
125
134
135
+
### Switches not available in the new sqlcmd (go-sqlcmd) yet
136
+
137
+
There are a few switches yet to be implemented in the new `sqlcmd` (go-sqlcmd) compared
138
+
to the original ODBC based `sqlcmd`, discussion [#293](https://github.com/microsoft/go-sqlcmd/discussions/292)
139
+
lists these switches. Please provide feedback in the discussion on which
140
+
switches are most important to you to have implemented next in the new sqlcmd.
141
+
142
+
Also, the XML Output command `:XML [On]|[Off]` is not implemented yet
143
+
in the new sqlcmd (go-sqlcmd).
144
+
126
145
### Miscellaneous enhancements
127
146
128
147
- Console output coloring (see below)
129
-
-`:Connect` now has an optional `-G` parameter to select one of the authentication methods for Azure SQL Database - `SqlAuthentication`, `ActiveDirectoryDefault`, `ActiveDirectoryIntegrated`, `ActiveDirectoryServicePrincipal`, `ActiveDirectoryManagedIdentity`, `ActiveDirectoryPassword`. If `-G` is not provided, either Integrated security or SQL Authentication will be used, dependent on the presence of a `-U`user name parameter.
148
+
-`:Connect` now has an optional `-G` parameter to select one of the authentication methods for Azure SQL Database - `SqlAuthentication`, `ActiveDirectoryDefault`, `ActiveDirectoryIntegrated`, `ActiveDirectoryServicePrincipal`, `ActiveDirectoryManagedIdentity`, `ActiveDirectoryPassword`. If `-G` is not provided, either Integrated security or SQL Authentication will be used, dependent on the presence of a `-U`username parameter.
130
149
- The new `--driver-logging-level` command line parameter allows you to see traces from the `go-mssqldb` client driver. Use `64` to see all traces.
131
150
- Sqlcmd can now print results using a vertical format. Use the new `-F vertical` command line option to set it. It's also controlled by the `SQLCMDFORMAT` scripting variable.
132
151
@@ -158,7 +177,7 @@ net_transport Named pipe
158
177
159
178
To use AAD auth, you can use one of two command line switches:
160
179
161
-
`-G` is (mostly) compatible with its usage in the prior version of sqlcmd. If a user name and password are provided, it will authenticate using AAD Password authentication. If a user name is provided it will use AAD Interactive authentication which may display a web browser. If no user name or password is provided, it will use a DefaultAzureCredential which attempts to authenticate through a variety of mechanisms.
180
+
`-G` is (mostly) compatible with its usage in the prior version of sqlcmd. If a username and password are provided, it will authenticate using AAD Password authentication. If a username is provided it will use AAD Interactive authentication which may display a web browser. If no username or password is provided, it will use a DefaultAzureCredential which attempts to authenticate through a variety of mechanisms.
162
181
163
182
`--authentication-method=` can be used to specify one of the following authentication types.
164
183
@@ -178,8 +197,8 @@ This method is currently not implemented and will fall back to `ActiveDirectoryD
178
197
179
198
`ActiveDirectoryPassword`
180
199
181
-
This method will authenticate using a user name and password. It will not work if MFA is required.
182
-
You provide the user name and password using the usual command line switches or SQLCMD environment variables.
200
+
This method will authenticate using a username and password. It will not work if MFA is required.
201
+
You provide the username and password using the usual command line switches or SQLCMD environment variables.
183
202
Set `AZURE_TENANT_ID` environment variable to the tenant id of the server if not using the default tenant of the user.
184
203
185
204
`ActiveDirectoryInteractive`
@@ -188,11 +207,11 @@ This method will launch a web browser to authenticate the user.
188
207
189
208
`ActiveDirectoryManagedIdentity`
190
209
191
-
Use this method when running sqlcmd on an Azure VM that has either a system-assigned or user-assigned managed identity. If using a user-assigned managed identity, set the user name to the ID of the managed identity. If using a system-assigned identity, leave user name empty.
210
+
Use this method when running sqlcmd on an Azure VM that has either a system-assigned or user-assigned managed identity. If using a user-assigned managed identity, set the username to the ID of the managed identity. If using a system-assigned identity, leave username empty.
192
211
193
212
`ActiveDirectoryServicePrincipal`
194
213
195
-
This method authenticates the provided user name as a service principal id and the password as the client secret for the service principal. Provide a user name in the form `<service principal id>@<tenant id>`. Set `SQLCMDPASSWORD` variable to the client secret. If using a certificate instead of a client secret, set `AZURE_CLIENT_CERTIFICATE_PATH` environment variable to the path of the certificate file.
214
+
This method authenticates the provided username as a service principal id and the password as the client secret for the service principal. Provide a username in the form `<service principal id>@<tenant id>`. Set `SQLCMDPASSWORD` variable to the client secret. If using a certificate instead of a client secret, set `AZURE_CLIENT_CERTIFICATE_PATH` environment variable to the path of the certificate file.
A partial localization suppport exists in go-sqlcmd for following languages for user visible content that also existed in ODBC based SQLCMD.
273
+
The new sqlcmd (go-sqlcmd) is localized for the following languages:
255
274
Chinese (Simplified) | Chinese (Traditional) | English (United States) | French | German | Italian | Japanese | Korean | Portuguese (Brazil) | Russian | Spanish
256
275
257
-
To get localized messages from SQLCMD user needs to set environment variable SQLCMD_LANG to a language tag as per BCP47 convention.
258
-
E.g.
276
+
Currently, the user visible strings that also existed in ODBC based sqlcmd are localized in the new sqlcmd, new strings (introduced with the new sqlcmd functionality) will be localized shortly.
277
+
278
+
To get localized messages from `sqlcmd` set environment variable SQLCMD_LANG to a language tag as per BCP47 convention.
279
+
e.g.
259
280
```
260
281
\git\go-sqlcmd>set SQLCMD_LANG=de-de
261
282
\git\go-sqlcmd>.\sqlcmd.exe -w 4
@@ -287,6 +308,7 @@ Any use of third-party trademarks or logos are subject to those third-party's po
0 commit comments