Reputation: 873
I want to get the SQL Server version into a variable in my bash script.
I tried using
sqlcmd -S localhost -U SA -Q 'select @@VERSION'
but it returns a string containing a bunch of other information too - eg: the copyright information, 86/x64? etc.
What is the correct way to get just the version?
Upvotes: 1
Views: 525
Reputation: 300719
Depends what you mean by 'SQL Server Version', but if you mean the build number:
sqlcmd -S localhost -U SA -Q "SELECT CAST(SERVERPROPERTY('ProductVersion') AS NVARCHAR(128))"
Example output:
13.0.5081.1
Upvotes: 4