如何使用T-SQL确定正在运行的SQL Server版本

时间:2022-09-21 08:23:12

I need help using T-SQL to figure-out the version of SQL Server running and execute different code sets based on weather SQL Server 2000 or Sql Server 2008 is running.

我需要帮助使用T-SQL来计算运行的SQL Server版本,并根据天气SQL Server 2000或Sql Server 2008运行执行不同的代码集。

8 个解决方案

#1


6  

SELECT @@VERSION?

Or one of the SERVERPROPERTY options?

或者其中一个SERVERPROPERTY选项?

#2


5  

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

#3


5  

@@VERSION / SERVERPROPERTY

@@ VERSION / SERVERPROPERTY

But you should also check

但你也应该检查一下

exec sp_dbcmptlevel 'dbname'

To ensure a certain feature works at the database's compatibility level.

确保某个功能在数据库的兼容级别上有效。

#4


4  

Just query the database - there is a @@VERSION property:

只查询数据库 - 有一个@@ VERSION属性:

SELECT @@VERSION

Returns version, processor architecture, build date, and operating system for the current installation of SQL Server.

返回当前SQL Server安装的版本,处理器体系结构,构建日期和操作系统。

As mentioned on the page, since all of this data is returned in one varchar, you can use the SERVERPROPERTY function to retrieve only the version:

如页面所述,由于所有这些数据都在一个varchar中返回,因此您可以使用SERVERPROPERTY函数仅检索版本:

SELECT SERVERPROPERTY('ProductVersion')

#5


1  

SELECT SERVERPROPERTY('productversion')

The digits before the first period will give you the major version: 10 = 2008, 9 = 2005, 8 = 2000.

第一个时期之前的数字将为您提供主要版本:10 = 2008,9 = 2005,8 = 2000。

#6


1  

Use to get the server SQL version:

用于获取服务器SQL版本:

SELECT SERVERPROPERTY('ProductVersion')
GO

Or for a more verbose command

或者更详细的命令

SELECT @@VERSION
GO

Also in here you can find a list of the releases's version numbers

此外,您还可以在此处找到版本的版本号列表

#7


0  

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

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

#8


0  

EXEC[MASTER].SYS.[XP_MSVER]--To  get  the  server version

#1


6  

SELECT @@VERSION?

Or one of the SERVERPROPERTY options?

或者其中一个SERVERPROPERTY选项?

#2


5  

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

#3


5  

@@VERSION / SERVERPROPERTY

@@ VERSION / SERVERPROPERTY

But you should also check

但你也应该检查一下

exec sp_dbcmptlevel 'dbname'

To ensure a certain feature works at the database's compatibility level.

确保某个功能在数据库的兼容级别上有效。

#4


4  

Just query the database - there is a @@VERSION property:

只查询数据库 - 有一个@@ VERSION属性:

SELECT @@VERSION

Returns version, processor architecture, build date, and operating system for the current installation of SQL Server.

返回当前SQL Server安装的版本,处理器体系结构,构建日期和操作系统。

As mentioned on the page, since all of this data is returned in one varchar, you can use the SERVERPROPERTY function to retrieve only the version:

如页面所述,由于所有这些数据都在一个varchar中返回,因此您可以使用SERVERPROPERTY函数仅检索版本:

SELECT SERVERPROPERTY('ProductVersion')

#5


1  

SELECT SERVERPROPERTY('productversion')

The digits before the first period will give you the major version: 10 = 2008, 9 = 2005, 8 = 2000.

第一个时期之前的数字将为您提供主要版本:10 = 2008,9 = 2005,8 = 2000。

#6


1  

Use to get the server SQL version:

用于获取服务器SQL版本:

SELECT SERVERPROPERTY('ProductVersion')
GO

Or for a more verbose command

或者更详细的命令

SELECT @@VERSION
GO

Also in here you can find a list of the releases's version numbers

此外,您还可以在此处找到版本的版本号列表

#7


0  

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

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

#8


0  

EXEC[MASTER].SYS.[XP_MSVER]--To  get  the  server version