Knowledgebase

How to Check the SQL Version in Windows CMD?

If you have ever needed to know exactly which version of SQL Server is running on your system, you’re not alone!

Whether you are troubleshooting, planning an upgrade, or just curious, knowing the SQL Server version is crucial. 

The good news is, you don’t need fancy tools or software; just a simple command in the Command Prompt (CMD) can give you all the details. 

In this guide, we will walk you through the process step by step in a way that’s easy to understand, even if you are not a tech expert.


Also Read: Guide to Check Node Version in Windows CMD


Why Knowing Your SQL Server Version Matters

Before we dive into commands, let’s quickly understand why checking the SQL version is important:

  • Compatibility – Some applications require a specific SQL Server version.
  • Troubleshooting – Knowing the version helps resolve errors effectively.
  • Updates and Security – Older versions may lack security patches, making updates essential.
  • Documentation – It’s good practice to document server environments for IT audits.

Now that we know why it’s important, let’s see how to check it using CMD!


Also Read: Guide to Check PHP Version in Windows CMD


Methods to Check SQL Version in CMD

Method 1: Using sqlcmd Command in CMD

sqlcmd is a command-line utility installed with SQL Server. It allows you to connect to SQL Server and execute queries directly from CMD. 

Here’s how to check your SQL Server version:

➔ To open Windows CMD, press ‘Windows Key + R’ on your keyboard.

➔ A dialog box will open. In that, Type ‘cmd’ in it & press ‘Enter.’ This will open the Command Prompt window.

➔ Now, you have to connect to SQL Server. For that, type the following command:

Copied!
sqlcmd -S <ServerName> -U <Username> -P <Password>

Here’s what each parameter means:

-S → Your server name (e.g., localhost or .\SQLEXPRESS).

-U → Your SQL Server username (like sa).

-P → Your password.

Tip: If you’re using Windows Authentication, replace -U and -P with -E to use your current Windows credentials.

Here is the example:

Copied!
sqlcmd -S <ServerName> -E

➔ Once connected, you have to type the following query:

Copied!
SELECT @@VERSION;
GO

After pressing Enter, CMD will display the complete SQL Server version, including:

SQL version details

Here, it is showing:

  • SQL Server edition – Express.
  • Version number (e.g., 16.0.1000.6) (X64)
  • Operating system version.

Also Read: Guide to Check MongoDB Version in Windows CMD


Method 2: Using osql Command (Older SQL Versions)

If you’re working with older SQL Server versions, osql might be available:

➔ To open Windows CMD, press ‘Windows Key + R’ on your keyboard.

 ➔ A dialog box will open. In that, Type ‘cmd’ in it & press ‘Enter.’ This will open the Command Prompt window.

➔ In that, you have to type the command:

Copied!
osql -S <ServerName> -U <Username> -P <Password>

Once it is connected, type:

Copied!
SELECT @@VERSION;
GO

Press Enter to see the version details.

SQL version details

*Note: osql is deprecated in newer versions of SQL Server, so sqlcmd is recommended.

Understanding the Version Output

After running the command, you will see output like this:

Microsoft SQL Server 2019 (RTM) – 15.0.2000.5 (X64) 

    Sep 24 2019 13:48:23 

    Copyright (C) 2019 Microsoft Corporation

    Express Edition (64-bit) on Windows 10 Pro 10.0 <X64>

Here’s how to read it:

  • 2019 → SQL Server version year
  • 15.0.2000.5 → Internal version/build number
  • Express Edition → Edition of SQL Server installed
  • 64-bit → Architecture

This information can help you identify compatibility with applications, plan upgrades, or verify server environments.


Also Read: How to Check Angular Version in Windows CMD?


Common Errors & Fixes

1. ‘sqlcmd’ is not recognized as an internal or external command

You need to ensure that SQL Server tools are installed. You may need to add the installation path to your system’s PATH environment variable.

2. Login failed for user ‘sa’

Double-check your username/password. If using Windows Authentication, replace -U <Username> -P <Password> with -E.

3. Server not found

In this case, you have to verify that the server name is correct and that SQL Server is running.

Conclusion

Checking your SQL Server version via CMD is quick, simple, and doesn’t require any additional tools. Whether you are a beginner or an experienced administrator, the sqlcmd utility provides a fast way to obtain detailed version information, helping you troubleshoot, plan, and maintain your SQL environment.

Next time you need to confirm your SQL version, remember, just a few commands in CMD are all it takes. No GUI, no hassle, no extra software. 

Just pure efficiency at your fingertips!