Skip to content
kotyniaPublic

About

Database Tool for SQL Server

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

45 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZenQuery - no installation Database Tool for SQL Server and SQLite

ZenQuery

Key Features

  • No Installation Required: a single exe, ultra-light and fast, perfect for remote server usage.
  • SQL Server and SQLite: connections are kept in a list; paste a connection string or fill in the fields.
  • Object Browser: tables, views, procedures, functions and triggers, loaded in the background so you can start querying right away. The search box filters live by object name (also schema.name), by column name and by definition text (objects found only by a column or in their definition are greyed). Drag an object into the editor to insert its name.
  • SQL Editor: syntax highlighting, autocomplete of column names, bookmarks, find and replace, line comments. F5 runs the query or the selected text.
  • Flexible Result Presentation: Grid, Grid Transpose (rows to columns), Text (Markdown tables, NULL as an empty cell) and Text Transpose. bit values are shown as 0 and 1.
  • Skip empty columns: optionally leave out the result columns that are NULL, or NULL or empty, in every row; the skipped columns are listed in the messages.
  • Grid: filter rows by text in any column, drag a column header into the editor to insert the column name, fast loading and scrolling of large result sets.
  • Export: right click a result grid > Export to Excel (.xlsx), XML, JSON or SQLite (a new table in a new or existing database) - the rows shown (row filter and sort applied), columns in their order, numbers and dates kept as numbers and dates, NULL as an empty cell / xsi:nil / null.
  • Script Generation: Create select, update, insert and delete scripts directly from the result window. Select rows or cells to generate scripts (NULL values become NULL / IS NULL).
  • Query History: Keep track of your executed queries and navigate through your history for efficient workflow.
  • Command Line Mode: Run queries from a terminal or script with sqlcmd-compatible switches; results are printed as Markdown tables.
  • JetBrains Mono font with an adjustable font size (About window), saved in zenQuery.xml next to the exe.

Command Line

Started with switches, zenQuery runs the query in the console instead of opening the GUI. The switches follow sqlcmd and are not case sensitive (-s = -S).

zenquery -s server -d database -u login -p password -q "select db_name(), @@servername, serverproperty('productversion') productversion"

Results are written as Markdown tables:

|Month   |Savings|
|--------|-------|
|January |$250   |
|February|$80    |

(2 rows affected)

With -frt (text transpose) each column becomes a row:

|Field  |i1     |i2      |
|-------|-------|--------|
|Month  |January|February|
|Savings|$250   |$80     |
Switch Description
-s server Server: host[\instance][,port]. Default: .
-d database Database. SQLite: database file
-u login Login. Without -p the password is read from the SQLCMDPASSWORD environment variable or prompted for
-p password Password
-e Trusted connection (Windows authentication); the default when -u is not given
-q "query" Query to run. MSSQL batches are separated by go lines
-i file [file ...] Read the query from one or more files (instead of -q); -, or -i without a file, is standard input
< script Without -q and -i, a script piped or redirected to zenquery is run (see below)
-o file Write results to a file (UTF-8) instead of the console
-f rp|rt Result format: rp text (default), rt text transpose (one row per column: field, i1, i2, ...). Can be written as -frt
-l seconds Login timeout (default 15)
-t seconds Query timeout (default 0 = none)
-provider name mssql (default) or sqlite
-skip-null Leave out the columns that are NULL in every row
-skip-empty Leave out the columns that are NULL or empty text in every row
-nocount No (n rows affected) lines and no note about skipped columns, like set nocount on (PRINT output is still written)
-ui Open the window instead: connected with these switches, the query (-q or -i, optional) pasted into a new query window, not executed. The terminal is not blocked
-c, -b Accepted for sqlcmd compatibility (the server certificate is always trusted; errors always set the exit code)
-? Help

Values may be attached to the switch as in sqlcmd (-sserver, -frt). Long switches also work with two dashes (--nocount). Errors are written to stderr in sqlcmd format (Msg 208, Level 16, State 1, ...) and a failed batch does not stop the following ones. Exit code: 0 on success, 1 if anything failed.

Multiline scripts are best passed on standard input - no quoting at all:

@'
DECLARE @database NVARCHAR(MAX) = 'sales';
PRINT 'database ' + @database;
'@ | zenquery -s sqlprod -e

Get-Content create_login.sql -Raw -Encoding UTF8 | zenquery -s sqlprod -e    # -Encoding UTF8: Windows PowerShell 5.1 reads files as ANSI
zenquery -s sqlprod -e < create_login.sql
zenquery -s sqlprod -e <<'SQL'
PRINT 'hello';
SQL

Scripts from files and standard input are read as UTF-8 (with or without a byte order mark), otherwise in the Windows ANSI code page. Windows PowerShell 5.1 sends piped text as ASCII unless $OutputEncoding = [System.Text.Encoding]::UTF8 is set first (PowerShell 7 sends UTF-8). With -u and a script on standard input, give the password with -p or in SQLCMDPASSWORD (it cannot be typed in). With -ui the piped script opens in the window.

Examples:

zenquery -s . -frt -q "select * from sys.databases where name = 'master'"
zenquery -s sqlprod,1433 -u report -i daily.sql -o daily.md
zenquery -provider sqlite -d data.db -q "select * from customers"
zenquery -ui -s sqlprod -d sales -i report.sql

Keyboard

Key Action
F5 Execute the query (or the selected text)
Alt+Break Cancel the running query
Ctrl+N New query window on the same connection
Ctrl+R Show / hide the results pane
F8 Show / hide the object browser
Ctrl+Space Autocomplete
Ctrl+O, Ctrl+S Open / save a SQL file

Linux and macOS

The command line mode also runs on Linux and macOS (bash, zsh, ...) as zenquery, a separate single-file build of the same code without the window. Everything above works the same except -ui, and switches start with - only (/home/me/script.sql is a path, not a switch). Results piped or redirected are written in UTF-8.

dotnet publish cli                                   # publish/linux/zenquery (linux-x64, needs the .NET 10 runtime)
dotnet publish cli -p:SelfContained=true             # no .NET needed on the machine
dotnet publish cli -r osx-arm64 -p:SelfContained=true

./zenquery -s sqlprod -u report -p "$PASS" -d sales <<'SQL'
SELECT TOP 10 * FROM orders ORDER BY id DESC;
SQL

On Linux -e (Windows authentication) needs Kerberos; use -u/-p for SQL logins.

System Requirements

  • Operating System: Microsoft Windows 10 or 11 (64-bit)
  • Framework: .NET 10 Desktop Runtime
  • Command line only (zenquery): Linux or macOS, x64 or arm64, with the .NET 10 runtime (or a self-contained build)

Build

dotnet build
dotnet publish

dotnet publish creates a single publish\zenQuery.exe (framework-dependent, win-x64); dotnet publish cli creates the command line publish/linux/zenquery (see Linux and macOS).

License

GNU General Public License v2, Copyright (C) 2005-2026 Marcin Kotynia marcin@kotynia.com. See LICENSE.

Third-party components keep their own licenses: Microsoft.Data.SqlClient and Scintilla5.NET (MIT), System.Data.SQLite (public domain), Scintilla and Lexilla (HPND), JetBrains Mono (SIL OFL 1.1).

ChangeLog

  • 2005: Initial version
  • 2006: Added SQLite support, search in objects definitions, and search by object name
  • 2023: Cleanup and upgrade to .NET 4.8, Release
  • 2026: Upgrade to .NET 10 and single-file publish, license changed to GNU GPL v2. New connection dialog, sqlcmd-compatible command line mode, Markdown text results, object browser with background loading and live search in names and definitions, result grid row filter and column drag, faster large result sets, JetBrains Mono with adjustable font size, new About window. Oracle support removed.

History

zenQuery was originally developed in 2005 as a lightweight tool for SQL Server. In 2006 it was rewritten based on Joseph Albahari Query Express. The tool was used internally for many years and was never released to the public. In 2015 the tool was published on GitHub. In 2023 the tool was cleaned up and upgraded to .NET 4.8. and Release version was published. In 2026 it was moved to .NET 10 and relicensed under the GNU General Public License v2.

Screenshots

Query History

Query History

Text

Text

About

Database Tool for SQL Server

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages