-
Notifications
You must be signed in to change notification settings - Fork 81
Implement :serverlist command #630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4197693
fb3825e
ebd4b2f
a1cbf57
8aa3cf3
e1b1dcd
4bea3f2
3412442
ec0a3cd
f241917
c103e26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -154,6 +154,41 @@ switches are most important to you to have implemented next in the new sqlcmd. | |||||||||||||||||||
| - `: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. | ||||||||||||||||||||
| - 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. | ||||||||||||||||||||
| - Sqlcmd can now print results using a vertical format. Use the new `--vertical` command line option to set it. It's also controlled by the `SQLCMDFORMAT` scripting variable. | ||||||||||||||||||||
| - `:help` displays a list of available sqlcmd commands. | ||||||||||||||||||||
| - `:serverlist` lists local SQL Server instances discovered via the SQL Server Browser service (UDP port 1434). The command queries the SQL Browser service and displays the server name and instance name for each discovered instance. If no instances are found or the Browser service is not running, no output is produced. Non-timeout errors are printed to stderr. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ``` | ||||||||||||||||||||
| 1> :serverlist | ||||||||||||||||||||
| MYSERVER\SQL2019 | ||||||||||||||||||||
| MYSERVER\SQL2022 | ||||||||||||||||||||
|
Comment on lines
+162
to
+163
|
||||||||||||||||||||
| MYSERVER\SQL2019 | |
| MYSERVER\SQL2022 | |
| MYSERVER\SQL2019 | |
| MYSERVER\SQL2022 |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example output doesn't show the behavior when the default MSSQLSERVER instance is present. According to the code (serverlist.go:82-83), the default instance produces two entries in the output: "(local)" and the actual server name (e.g., "MYSERVER"). Consider adding an example showing this case, such as " (local)\n MYSERVER\n MYSERVER\SQL2019".
| MYSERVER\SQL2019 | |
| MYSERVER\SQL2022 | |
| (local) | |
| MYSERVER | |
| MYSERVER\SQL2019 |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This batch script has a syntax error. The file size test operator %~z only works within a FOR loop context, not directly in an IF statement. A correct alternative would be to use FOR /F to check the file size, or simply check if the file exists and has content using: "if exist errors.log (for %%A in (errors.log) do if %%~zA GTR 0 type errors.log)"
| if exist errors.log if not "%%~z errors.log"=="0" type errors.log | |
| if exist errors.log (for %%A in (errors.log) do if %%~zA GTR 0 type errors.log) |
Uh oh!
There was an error while loading. Please reload this page.