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
+48-14Lines changed: 48 additions & 14 deletions
Display the source diff
Display the rich diff
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.
@@ -58,7 +67,7 @@ Use `sqlcmd --help` to view all the available sub-commands. Use `sqlcmd -?` to
58
67
59
68
### The ~/.sqlcmd/sqlconfig file
60
69
61
-
Each time `sqlcmd create` completes, a new context is created (e.g. mssql, mssql2, mssql3 etc.). A context contains the endpoint and user configuation detail. To switch between contexts, run `sqlcmd config use <context-name>`, to view name of the current context, run `sqlcmd config current-context`, to list all contexts, run `sqlcmd config get-contexts`.
70
+
Each time `sqlcmd create` completes, a new context is created (e.g. mssql, mssql2, mssql3 etc.). A context contains the endpoint and user configuration detail. To switch between contexts, run `sqlcmd config use <context-name>`, to view name of the current context, run `sqlcmd config current-context`, to list all contexts, run `sqlcmd config get-contexts`.
62
71
63
72
To view connection strings (ODBC/ADO.NET/JDBC etc.) for the current context and user & endpoint details for all contexts held in the `~/.sqlcmd/sqlconfig` file:
64
73
@@ -88,22 +97,22 @@ sqlcmd delete
88
97
89
98
### Backwards compatibility with ODBC sqlcmd
90
99
91
-
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
102
111
The `sqlcmd` project aims to be a complete port of the original ODBC sqlcmd to the `Go` language, utilizing the [go-mssqldb][] driver. For full documentation of the tool and installation instructions, see [go-sqlcmd-utility][].
103
112
104
113
### Changes in behavior from the ODBC based sqlcmd
105
114
106
-
The following switches have different behavior in this version of `sqlcmd` compared to the oroignla ODBC based `sqlcmd`.
115
+
The following switches have different behavior in this version of `sqlcmd` compared to the original ODBC based `sqlcmd`.
107
116
108
117
-`-P` switch will be removed. Passwords for SQL authentication can only be provided through these mechanisms:
109
118
@@ -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.
196
215
197
216
#### Environment variables for AAD auth
198
217
@@ -250,6 +269,20 @@ If you are developing on Windows, you can use docker or WSL to run the tests on
250
269
docker run -rm -e SQLCMDSERVER=<yourserver> -e SQLCMDUSER=<youruser> -e SQLCMDPASSWORD=<yourpassword> -v i:\git\go-sqlcmd:/go-sqlcmd -w /go-sqlcmd golang:1.16 go test ./...
251
270
```
252
271
272
+
## Localization
273
+
The new sqlcmd (go-sqlcmd) is localized for the following languages:
274
+
Chinese (Simplified) | Chinese (Traditional) | English (United States) | French | German | Italian | Japanese | Korean | Portuguese (Brazil) | Russian | Spanish
275
+
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.
280
+
```
281
+
\git\go-sqlcmd>set SQLCMD_LANG=de-de
282
+
\git\go-sqlcmd>.\sqlcmd.exe -w 4
283
+
sqlcmd.exe: error: sqlcmd.exe: '-w 4': Der Wert muss größer als 8 und kleiner als 65536 sein.
284
+
```
285
+
253
286
## Contributing
254
287
255
288
This project welcomes contributions and suggestions. Most contributions require you to agree to a
@@ -275,6 +308,7 @@ Any use of third-party trademarks or logos are subject to those third-party's po
0 commit comments