Skip to content

Commit e70df94

Browse files
committed
Merge branch 'main' into stuartpa/sqlcmd-urls
2 parents abff8b6 + efaa12e commit e70df94

File tree

20 files changed

+529
-178
lines changed

20 files changed

+529
-178
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"request": "launch",
2525
"mode" : "auto",
2626
"program": "${workspaceFolder}/cmd/modern",
27-
"args" : ["-Q", "EXIT(select net_transport from sys.dm_exec_connections)"],
27+
"args" : ["-Q", "EXIT(select net_transport from sys.dm_exec_connections)"],
2828
},
2929
{
3030
"name" : "Run file query",

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"go.lintTool": "golangci-lint",
3+
"go.lintOnSave": "workspace"
4+
}

NOTICE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,8 @@ Apache License
556556
## github.com/docker/docker
557557

558558
* Name: github.com/docker/docker
559-
* Version: v20.10.21
560-
* License: [Apache-2.0](https://github.com/docker/docker/blob/v20.10.21/LICENSE)
559+
* Version: v20.10.24
560+
* License: [Apache-2.0](https://github.com/docker/docker/blob/v20.10.24/LICENSE)
561561

562562
```
563563

README.md

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SQLCMD CLI - Preview
1+
# SQLCMD CLI
22

33
This repo contains the `sqlcmd` command line tool and go packages for working with Microsoft SQL Server, Azure SQL Database, and Azure Synapse.
44

@@ -8,13 +8,22 @@ This repo contains the `sqlcmd` command line tool and go packages for working wi
88

99
### Windows
1010

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.
1212

1313
#### WinGet
1414

15+
| Install: | Upgrade: |
16+
| ----------------------- |-----------------------------|
17+
| `winget install sqlcmd` | `winget uninstall sqlcmd`** |
18+
| | `winget install sqlcmd` |
19+
20+
** temporary workaround, while we fix `winget upgrade`
21+
22+
#### Choco
23+
1524
| Install: | Upgrade: |
16-
| ----------------------- | ----------------------- |
17-
| `winget install sqlcmd` | `winget upgrade sqlcmd` |
25+
| ----------------------- |-------------------------|
26+
| `choco install sqlcmd` | `choco upgrade sqlcmd` |
1827

1928
### macOS
2029

@@ -58,7 +67,7 @@ Use `sqlcmd --help` to view all the available sub-commands. Use `sqlcmd -?` to
5867

5968
### The ~/.sqlcmd/sqlconfig file
6069

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`.
6271

6372
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:
6473

@@ -88,22 +97,22 @@ sqlcmd delete
8897

8998
### Backwards compatibility with ODBC sqlcmd
9099

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:
92101

93102
```
94103
sqlcmd -q "SELECT @@version"
95104
sqlcmd
96105
```
97106

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.
99108

100109
## Sqlcmd
101110

102111
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][].
103112

104113
### Changes in behavior from the ODBC based sqlcmd
105114

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`.
107116

108117
- `-P` switch will be removed. Passwords for SQL authentication can only be provided through these mechanisms:
109118

@@ -123,10 +132,20 @@ The following switches have different behavior in this version of `sqlcmd` compa
123132
- 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.
124133
- `-i` now requires multiple arguments for the switch to be separated by `,`.
125134

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+
126145
### Miscellaneous enhancements
127146

128147
- 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.
130149
- 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.
131150
- 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.
132151

@@ -158,7 +177,7 @@ net_transport Named pipe
158177

159178
To use AAD auth, you can use one of two command line switches:
160179

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.
162181

163182
`--authentication-method=` can be used to specify one of the following authentication types.
164183

@@ -178,8 +197,8 @@ This method is currently not implemented and will fall back to `ActiveDirectoryD
178197

179198
`ActiveDirectoryPassword`
180199

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.
183202
Set `AZURE_TENANT_ID` environment variable to the tenant id of the server if not using the default tenant of the user.
184203

185204
`ActiveDirectoryInteractive`
@@ -188,11 +207,11 @@ This method will launch a web browser to authenticate the user.
188207

189208
`ActiveDirectoryManagedIdentity`
190209

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.
192211

193212
`ActiveDirectoryServicePrincipal`
194213

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.
196215

197216
#### Environment variables for AAD auth
198217

@@ -250,6 +269,20 @@ If you are developing on Windows, you can use docker or WSL to run the tests on
250269
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 ./...
251270
```
252271

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+
253286
## Contributing
254287

255288
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
275308
[Homebrew]: https://formulae.brew.sh/formula/sqlcmd
276309
[Linuxbrew]: https://docs.brew.sh/Homebrew-on-Linux
277310
[Winget]: https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/Sqlcmd
311+
[Choco]: https://community.chocolatey.org/packages/sqlcmd
278312
[Docker]: https://www.docker.com/products/docker-desktop/
279313
[Podman]: https://podman-desktop.io/downloads/
280314
[releases page]: https://github.com/microsoft/go-sqlcmd/releases/latest

0 commit comments

Comments
 (0)