SQL Server
SELECT @@VERSION;
One string with edition, version number, OS and architecture. SERVERPROPERTY('ProductVersion') (for example 17.0.4035.5) and SERVERPROPERTY('Edition') give structured fields.
The first thing any support engineer asks for: exact engine and version. Every engine has a one-liner.
Filed under Sessions & admin
Trivial everywhere, just five different spellings. If you are branching application logic on the version, prefer the structured sources (SERVERPROPERTY, server_version_num, v$version) over parsing the banner string.
One line each, no shared spelling. The version string contents also differ: some include the OS build, some just the number.
SELECT @@VERSION;
One string with edition, version number, OS and architecture. SERVERPROPERTY('ProductVersion') (for example 17.0.4035.5) and SERVERPROPERTY('Edition') give structured fields.
SELECT version();
Full banner string. SHOW server_version gives just the number; current_setting('server_version_num') returns it as an integer string such as 180006, which casts cleanly for comparisons.
SELECT VERSION();
Just the version number, such as 8.4.11, sometimes with a distribution suffix (8.0.36-0ubuntu0.22.04.1). @@version_comment names the build, and SHOW VARIABLES LIKE 'version%' adds the compile OS and machine.
SELECT sqlite_version();
Library version like 3.45.1. PRAGMA compile_options lists build-time flags; sqlite_source_id() the exact source snapshot.
SELECT banner FROM v$version;
-- or: SELECT BANNER_FULL FROM v$version;
From 18c on, v$version returns one row and BANNER_FULL adds the release update (Version 23.26.3.0.0); older releases list a row per component. Reading it needs dictionary access such as SELECT_CATALOG_ROLE.
Syntax and behavior differ by release: PostgreSQL INCLUDE since 11, MySQL descending indexes honored since 8.0, SQL Server DROP IF EXISTS since 2016. Version detection avoids runtime errors.
Yes, all of these are session-local reads with no locking; safe to call any time, including from health checks.
You lack SELECT on v$version (it is a dictionary view). Ask for SELECT_CATALOG_ROLE or use the data dictionary alternative product_component_version.
The identity card query: who am I logged in as, where am I, and what is my session id.
The who-is-connected view, including state and the current statement, needed before you kill anything.
SQLly is a native SQL workbench for macOS, Windows and Linux. Its formatter and plan viewer work in all five dialects.