How to check SQL server version name using command prompt?

This guide provides a concise method to check your SQL Server version directly from the command prompt. Follow these simple steps for a quick and efficient check.

In this Guide:

1. Open a Command Prompt Window

  • Search for "cmd" in the Windows search bar and open the Command Prompt.

2. Connect to SQL Server using sqlcmd

  • Use the following command to connect to your SQL Server instance:
sqlcmd -S <servername>\\<instancename>
  • Replace <servername> with the name of your server (e.g., "your_server_name") and <instancename> with the name of your SQL Server instance (e.g., "MSSQLSERVER"). If you're connecting to the default instance, you can omit the <instancename> part.

3. Execute the Query

  • At the 1> prompt, enter the following query:

SQL

SELECT @@version;
  • Press Enter.

4. View the Version Information

  • At the 2> prompt, type go and press Enter. This will execute the query.
  • The output will display detailed information about your SQL Server version, including the edition, version number, and build information.

Example

C:\\>sqlcmd -S your_server_name\\MSSQLSERVER
1> SELECT @@version;
2> go
Microsoft SQL Server 2022 (RTM-CU17) (x64)
    Copyright (C) 2019 Microsoft Corporation
    Standard Edition (64-bit) on Windows
    (Build 15.0.4244.1)

In this example:

  • Microsoft SQL Server 2022 (RTM-CU17): This is the SQL Server version.
  • Standard Edition (64-bit): This is the SQL Server edition.
  • (Build 15.0.4244.1): This is the build number of the SQL Server installation.

Note:

  • If you're connecting to a remote SQL Server instance, you may need to provide authentication credentials (username and password) using the U and P options with the sqlcmd command.
  • For more information about the sqlcmd utility and its options, refer to the Microsoft SQL Server documentation.

Frequently asked questions:

  • Why would I need to know my SQL Server version?

    Knowing your SQL Server version is crucial for:

      1. Compatibility: Ensuring compatibility with software, drivers, and tools.
      2. Troubleshooting: Identifying potential issues specific to certain versions.
      3. Updates: Determining available updates and patches.
      4. Support: Providing necessary information to support teams.

  • Are there other ways to check the SQL Server version?

    Yes, you can also check the SQL Server version through:

      1. SQL Server Management Studio (SSMS): By querying the @@version system function.
      2. SQL Server Configuration Manager: In the properties of the SQL Server service.

  • What if I encounter errors while using the command prompt?

      1. Check your connection string: Ensure the server name and instance name are correct.
      2. Verify SQL Server service status: Make sure the SQL Server service is running.
      3. Check for network connectivity: Confirm that your computer can communicate with the SQL Server instance.
      4. Review error messages: Carefully examine any error messages for clues to the issue.