If all you care about is the version alone, then all you need is…
SELECT @@VERSION
In my work, I find I also sometimes need to know more information about the underlying system.
SELECT
SERVERPROPERTY('LicenseType') AS LicenseType,
SERVERPROPERTY('edition') AS SQLEdition,
@@VERSION AS SQLVersion
Which produces:
Microsoft SQL Server 2017 (RTM-GDR) (KB4505224) - 14.0.2027.2 (X64) Jun 15 2019 00:26:19 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Windows 10 Professional 10.0 <X64>...