如何检查SQL Server版本

时间:2022-06-30 20:32:05

What are the possible ways to determine the deployed SQL Server version?

确定部署的SQL Server版本的可能方法有哪些?

I’ve tried to do it using the SQL Server software. I want to do it using a command line SQL statement.

我试过使用SQL Server软件。我想使用命令行SQL语句来完成它。

3 个解决方案

#1


152  

Following are possible ways to see the version:

以下是查看版本的可能方法:

Method 1: Connect to the instance of SQL Server, and then run the following query:

方法1:连接到SQL Server实例,然后运行以下查询:

Select @@version

An example of the output of this query is as follows:

此查询的输出示例如下:

Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)   Mar 29 2009 
10:11:52   Copyright (c) 1988-2008 Microsoft Corporation  Express 
Edition (64-bit) on Windows NT 6.1 <X64> (Build 7600: )

Method 2: Connect to the server by using Object Explorer in SQL Server Management Studio. After Object Explorer is connected, it will show the version information in parentheses, together with the user name that is used to connect to the specific instance of SQL Server.

方法2:使用SQL Server Management Studio中的对象资源管理器连接到服务器。连接对象资源管理器后,它将在括号中显示版本信息,以及用于连接到特定SQL Server实例的用户名。

Method 3: Look at the first few lines of the Errorlog file for that instance. By default, the error log is located at Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\LOG\ERRORLOG and ERRORLOG.n files. The entries may resemble the following:

方法3:查看该实例的Errorlog文件的前几行。默认情况下,错误日志位于Program Files \ Microsoft SQL Server \ MSSQL.n \ MSSQL \ LOG \ ERRORLOG和ERRORLOG.n文件中。条目可能类似于以下内容:

2011-03-27 22:31:33.50 Server      Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)                 Mar 29 2009 10:11:52                 Copyright (c) 1988-2008 Microsoft Corporation                Express Edition (64-bit) on Windows NT 6.1 <X64> (Build 7600: )

As you can see, this entry gives all the necessary information about the product, such as version, product level, 64-bit versus 32-bit, the edition of SQL Server, and the OS version on which SQL Server is running.

如您所见,此条目提供了有关产品的所有必要信息,例如版本,产品级别,64位与32位,SQL Server版本以及运行SQL Server的操作系统版本。

Method 4: Connect to the instance of SQL Server, and then run the following query:

方法4:连接到SQL Server实例,然后运行以下查询:

SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')

Note This query works with any instance of SQL Server 2000 or of a later version

注意此查询适用于SQL Server 2000或更高版本的任何实例

#2


6  

declare @sqlVers numeric(4,2)
select @sqlVers = left(cast(serverproperty('productversion') as varchar), 4)

Gives 8.00, 9.00, 10.00 and 10.50 for SQL 2000, 2005, 2008 and 2008R2 respectively.

分别为SQL 2000,2005,2008和2008R2提供8.00,9.00,10.00和10.50。

Also, Try the system extended procedure xp_msver. You can call this stored procedure like

另外,尝试系统扩展过程xp_msver。你可以像这样调用这个存储过程

exec master..xp_msver

#3


0  

select charindex(  'Express',@@version)

if this value is 0 is not a express edition

如果该值为0则不是快递版

#1


152  

Following are possible ways to see the version:

以下是查看版本的可能方法:

Method 1: Connect to the instance of SQL Server, and then run the following query:

方法1:连接到SQL Server实例,然后运行以下查询:

Select @@version

An example of the output of this query is as follows:

此查询的输出示例如下:

Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)   Mar 29 2009 
10:11:52   Copyright (c) 1988-2008 Microsoft Corporation  Express 
Edition (64-bit) on Windows NT 6.1 <X64> (Build 7600: )

Method 2: Connect to the server by using Object Explorer in SQL Server Management Studio. After Object Explorer is connected, it will show the version information in parentheses, together with the user name that is used to connect to the specific instance of SQL Server.

方法2:使用SQL Server Management Studio中的对象资源管理器连接到服务器。连接对象资源管理器后,它将在括号中显示版本信息,以及用于连接到特定SQL Server实例的用户名。

Method 3: Look at the first few lines of the Errorlog file for that instance. By default, the error log is located at Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\LOG\ERRORLOG and ERRORLOG.n files. The entries may resemble the following:

方法3:查看该实例的Errorlog文件的前几行。默认情况下,错误日志位于Program Files \ Microsoft SQL Server \ MSSQL.n \ MSSQL \ LOG \ ERRORLOG和ERRORLOG.n文件中。条目可能类似于以下内容:

2011-03-27 22:31:33.50 Server      Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)                 Mar 29 2009 10:11:52                 Copyright (c) 1988-2008 Microsoft Corporation                Express Edition (64-bit) on Windows NT 6.1 <X64> (Build 7600: )

As you can see, this entry gives all the necessary information about the product, such as version, product level, 64-bit versus 32-bit, the edition of SQL Server, and the OS version on which SQL Server is running.

如您所见,此条目提供了有关产品的所有必要信息,例如版本,产品级别,64位与32位,SQL Server版本以及运行SQL Server的操作系统版本。

Method 4: Connect to the instance of SQL Server, and then run the following query:

方法4:连接到SQL Server实例,然后运行以下查询:

SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')

Note This query works with any instance of SQL Server 2000 or of a later version

注意此查询适用于SQL Server 2000或更高版本的任何实例

#2


6  

declare @sqlVers numeric(4,2)
select @sqlVers = left(cast(serverproperty('productversion') as varchar), 4)

Gives 8.00, 9.00, 10.00 and 10.50 for SQL 2000, 2005, 2008 and 2008R2 respectively.

分别为SQL 2000,2005,2008和2008R2提供8.00,9.00,10.00和10.50。

Also, Try the system extended procedure xp_msver. You can call this stored procedure like

另外,尝试系统扩展过程xp_msver。你可以像这样调用这个存储过程

exec master..xp_msver

#3


0  

select charindex(  'Express',@@version)

if this value is 0 is not a express edition

如果该值为0则不是快递版