SERVERPROPERTY (Transact-SQL)SERVERPROPERTY (Transact-SQL)

適用範圍:Applies to: 是SQL ServerSQL Server (所有支援的版本) yesSQL ServerSQL Server (all supported versions) 是Azure SQL DatabaseAzure SQL DatabaseYesAzure SQL DatabaseAzure SQL Database 是Azure SQL 受控執行個體Azure SQL Managed InstanceYesAzure SQL 受控執行個體Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics 是平行處理資料倉儲Parallel Data Warehouseyes平行處理資料倉儲Parallel Data Warehouse適用範圍:Applies to: 是SQL ServerSQL Server (所有支援的版本) yesSQL ServerSQL Server (all supported versions) 是Azure SQL DatabaseAzure SQL DatabaseYesAzure SQL DatabaseAzure SQL Database 是Azure SQL 受控執行個體Azure SQL Managed InstanceYesAzure SQL 受控執行個體Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics 是平行處理資料倉儲Parallel Data Warehouseyes平行處理資料倉儲Parallel Data Warehouse

傳回有關伺服器執行個體的屬性資訊。Returns property information about the server instance.

主題連結圖示 Transact-SQL 語法慣例Topic link icon Transact-SQL Syntax Conventions

語法Syntax

SERVERPROPERTY ( 'propertyname' )  

重要

SQL ServerSQL ServerAzure SQL DatabaseAzure SQL DatabaseDatabase EngineDatabase Engine 版本號碼無法相互比較,而代表這些個別產品的內部組建編號。The Database EngineDatabase Engine version numbers for SQL ServerSQL Server and Azure SQL DatabaseAzure SQL Database are not comparable with each other, and represent internal build numbers for these separate products. Azure SQL DatabaseAzure SQL DatabaseDatabase EngineDatabase Engine 以與 SQL Server Database EngineSQL Server Database Engine 相同的程式碼基底為基礎。The Database EngineDatabase Engine for Azure SQL DatabaseAzure SQL Database is based on the same code base as the SQL Server Database EngineSQL Server Database Engine. 最重要的是,Azure SQL DatabaseAzure SQL Database 中的 Database EngineDatabase Engine 一律會有最新的 SQL Database EngineDatabase Engine 位元。Most importantly, the Database EngineDatabase Engine in Azure SQL DatabaseAzure SQL Database always has the newest SQL Database EngineDatabase Engine bits. 第 12 版的 Azure SQL DatabaseAzure SQL Database 比第 15 版的 SQL ServerSQL Server 新。Version 12 of Azure SQL DatabaseAzure SQL Database is newer than version 15 of SQL ServerSQL Server.

注意

若要檢視 SQL Server 2014 與更早版本的 Transact-SQL 語法,請參閱舊版文件To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.

引數Arguments

propertynamepropertyname
這是包含要傳回伺服器之屬性資訊的運算式。Is an expression that contains the property information to be returned for the server. propertyname 可以是下列值之一。propertyname can be one of the following values.

屬性Property 傳回的值Values returned
BuildClrVersionBuildClrVersion 建立 SQL ServerSQL Server 執行個體時所用的 MicrosoftMicrosoft.NET Framework.NET Framework 通用語言執行平台 (CLR) 版本。Version of the MicrosoftMicrosoft.NET Framework.NET Framework common language runtime (CLR) that was used while building the instance of SQL ServerSQL Server.

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
定序Collation 伺服器預設定序的名稱。Name of the default collation for the server.

NULL = 輸入無效,或發生錯誤。NULL = Input is not valid, or an error.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
CollationIDCollationID SQL ServerSQL Server 定序的識別碼。ID of the SQL ServerSQL Server collation.

基底資料類型:intBase data type: int
ComparisonStyleComparisonStyle Windows 的定序比較樣式。Windows comparison style of the collation.

基底資料類型:intBase data type: int
ComputerNamePhysicalNetBIOSComputerNamePhysicalNetBIOS SQL ServerSQL Server 執行個體目前執行所在之本機電腦的 NetBIOS 名稱。NetBIOS name of the local computer on which the instance of SQL ServerSQL Server is currently running.

如果是容錯移轉叢集中的 SQL ServerSQL Server 叢集執行個體,當 SQL ServerSQL Server 執行個體容錯移轉到容錯移轉叢集中的其他節點時,這個值會跟著改變。For a clustered instance of SQL ServerSQL Server on a failover cluster, this value changes as the instance of SQL ServerSQL Server fails over to other nodes in the failover cluster.

SQL ServerSQL Server 的獨立執行個體中,這個值會維持不變,且會傳回與 MachineName 屬性相同的值。On a stand-alone instance of SQL ServerSQL Server, this value remains constant and returns the same value as the MachineName property.

注意: 如果 SQL ServerSQL Server 執行個體在容錯移轉叢集中,且您想要取得容錯移轉叢集執行個體的名稱,請使用 MachineName 屬性。Note: If the instance of SQL ServerSQL Server is in a failover cluster and you want to obtain the name of the failover clustered instance, use the MachineName property.

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
版本Edition 已安裝的 SQL ServerSQL Server 執行個體產品版本。Installed product edition of the instance of SQL ServerSQL Server. 使用這個屬性值決定功能和限制,例如根據 SQL Server 版本計算容量限制Use the value of this property to determine the features and the limits, such as Compute Capacity Limits by Edition of SQL Server. 64 位元版的 Database EngineDatabase Engine 會將 (64 位元) 附加至版本中。64-bit versions of the Database EngineDatabase Engine append (64-bit) to the version.

傳回:Returns:

'Enterprise Edition''Enterprise Edition'

「Enterprise 版:核心授權」'Enterprise Edition: Core-based Licensing'

'Enterprise Evaluation Edition''Enterprise Evaluation Edition'

'Business Intelligence Edition''Business Intelligence Edition'

'Developer Edition''Developer Edition'

'Express Edition''Express Edition'

'Express Edition with Advanced Services''Express Edition with Advanced Services'

'Standard Edition''Standard Edition'

'Web Edition''Web Edition'

'SQL Azure' 表示 SQL DatabaseSQL DatabaseMicrosoft Azure Synapse AnalyticsMicrosoft Azure Synapse Analytics'SQL Azure' indicates SQL DatabaseSQL Database or Microsoft Azure Synapse AnalyticsMicrosoft Azure Synapse Analytics

'Azure SQL Edge Developer' 表示 Azure SQL Edge 的僅限開發版本'Azure SQL Edge Developer' indicates the development only edition for Azure SQL Edge

'Azure SQL Edge' 表示 Azure SQL Edge 的付費版本'Azure SQL Edge' indicates the paid edition for Azure SQL Edge

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
EditionIDEditionID EditionID 表示安裝的 SQL ServerSQL Server 執行個體產品版本。EditionID represents the installed product edition of the instance of SQL ServerSQL Server. 使用這個屬性值決定功能和限制,例如根據 SQL Server 版本計算容量限制Use the value of this property to determine features and limits, such as Compute Capacity Limits by Edition of SQL Server.

1804890536 = Enterprise1804890536 = Enterprise

1872460670 = Enterprise Edition:核心授權1872460670 = Enterprise Edition: Core-based Licensing

610778273= Enterprise Evaluation610778273= Enterprise Evaluation

284895786 = Business Intelligence284895786 = Business Intelligence

-2117995310 = Developer-2117995310 = Developer

-1592396055 = Express-1592396055 = Express

-133711905 = Express with Advanced Services-133711905= Express with Advanced Services

-1534726760 = Standard-1534726760 = Standard

1293598313 = Web1293598313 = Web

1674378470 = SQL DatabaseSQL DatabaseAzure Synapse AnalyticsAzure Synapse Analytics1674378470 = SQL DatabaseSQL Database or Azure Synapse AnalyticsAzure Synapse Analytics

-1461570097 = Azure SQL Edge 開發人員-1461570097 = Azure SQL Edge Developer

1994083197 = Azure SQL Edge1994083197 = Azure SQL Edge

基底資料型別:bigintBase data type: bigint
EngineEditionEngineEdition 安裝在伺服器上之 Database EngineDatabase Engine 執行個體的 SQL ServerSQL Server 版本。Database EngineDatabase Engine edition of the instance of SQL ServerSQL Server installed on the server.

1 = Personal 或 Desktop Engine (不適用於 SQL Server 2005 (9.x)SQL Server 2005 (9.x) 和更新版本中)。1 = Personal or Desktop Engine (Not available in SQL Server 2005 (9.x)SQL Server 2005 (9.x) and later versions.)

2 = Standard (Standard、Web 和 Business Intelligence 都會傳回這個值)。2 = Standard (This is returned for Standard, Web, and Business Intelligence.)

3 = Enterprise (Evaluation、Developer 和 Enterprise 版本都會傳回這個項目。)3 = Enterprise (This is returned for Evaluation, Developer, and Enterprise editions.)

4 = Express (Express、Express with Tools 和 Express with Advanced Services 都會傳回這個項目)4 = Express (This is returned for Express, Express with Tools, and Express with Advanced Services)

5 = SQL DatabaseSQL Database5 = SQL DatabaseSQL Database

6 = Microsoft Azure Synapse AnalyticsMicrosoft Azure Synapse Analytics6 = Microsoft Azure Synapse AnalyticsMicrosoft Azure Synapse Analytics

8 = Azure SQL 受控執行個體Azure SQL Managed Instance8 = Azure SQL 受控執行個體Azure SQL Managed Instance

9 = Azure SQL Edge (這會針對 Azure SQL Edge 的所有版本傳回)9 = Azure SQL Edge (This is returned for all editions of Azure SQL Edge)

11 = Azure Synapse 無伺服器 SQL 集區11 = Azure Synapse serverless SQL pool

基底資料類型:intBase data type: int
FilestreamConfiguredLevelFilestreamConfiguredLevel 已設定的 FILESTREAM 存取層級。The configured level of FILESTREAM access. 如需詳細資訊,請參閱檔案資料流存取層級For more information, see filestream access level.

基底資料類型:intBase data type: int
FilestreamEffectiveLevelFilestreamEffectiveLevel 有效的 FILESTREAM 存取層級。The effective level of FILESTREAM access. 如果此層級已變更而且執行個體重新啟動或電腦重新啟動已暫止,這個值就可能會與 FilestreamConfiguredLevel 不同。This value can be different than the FilestreamConfiguredLevel if the level has changed and either an instance restart or a computer restart is pending. 如需詳細資訊,請參閱檔案資料流存取層級For more information, see filestream access level.

基底資料類型:intBase data type: int
FilestreamShareNameFilestreamShareName FILESTREAM 所使用之共用的名稱。The name of the share used by FILESTREAM.

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
HadrManagerStatusHadrManagerStatus 適用對象SQL Server 2012 (11.x)SQL Server 2012 (11.x) 及更新版本。Applies to: SQL Server 2012 (11.x)SQL Server 2012 (11.x) and later.

指出 Always On 可用性群組Always On availability groups 管理員是否已經啟動。Indicates whether the Always On 可用性群組Always On availability groups manager has started.

0 = 未啟動,暫止通訊。0 = Not started, pending communication.

1 = 已啟動且在執行中。1 = Started and running.

2 = 未啟動且失敗。2 = Not started and failed.

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料類型:intBase data type: int
InstanceDefaultBackupPathInstanceDefaultBackupPath 適用於SQL Server 2019 (15.x)SQL Server 2019 (15.x) 與更新版本。Applies to: SQL Server 2019 (15.x)SQL Server 2019 (15.x) and later.

執行個體備份檔案的預設路徑名稱。Name of the default path to the instance backup files.
InstanceDefaultDataPathInstanceDefaultDataPath 適用對象SQL Server 2012 (11.x)SQL Server 2012 (11.x) 至目前版本 (從 2015 晚期開始的更新)。Applies to: SQL Server 2012 (11.x)SQL Server 2012 (11.x) through current version in updates beginning in late 2015.

執行個體資料檔案的預設路徑名稱。Name of the default path to the instance data files.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
InstanceDefaultLogPathInstanceDefaultLogPath 適用對象SQL Server 2012 (11.x)SQL Server 2012 (11.x) 至目前版本 (從 2015 晚期開始的更新)。Applies to: SQL Server 2012 (11.x)SQL Server 2012 (11.x) through current version in updates beginning in late 2015.

執行個體記錄檔的預設路徑名稱。Name of the default path to the instance log files.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
InstanceNameInstanceName 使用者所連接之執行個體的名稱。Name of the instance to which the user is connected.

如果執行個體名稱是預設執行個體、輸入無效,或發生錯誤,便傳回 NULL。Returns NULL if the instance name is the default instance, if the input is not valid, or error.

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
IsAdvancedAnalyticsInstalledIsAdvancedAnalyticsInstalled 若在設定時已安裝 [進階分析] 功能,則會傳回 1;否則會傳回 0。Returns 1 if the Advanced Analytics feature was installed during setup; 0 if Advanced Analytics was not installed.

基底資料類型:intBase data type: int
IsBigDataClusterIsBigDataCluster 從 CU4 開始在 SQL Server 2019 (15.x)SQL Server 2019 (15.x) 中引進。Introduced in SQL Server 2019 (15.x)SQL Server 2019 (15.x) beginning with CU4.

如果執行個體是 SQL Server 巨量資料叢集,則傳回 1;否則傳回 0。Returns 1 if the instance is SQL Server Big Data Cluster; 0 if not.

基底資料類型:intBase data type: int
IsClusteredIsClustered 伺服器執行個體設定在容錯移轉叢集中。Server instance is configured in a failover cluster.

1 = 叢集。1 = Clustered.

0 = 非叢集。0 = Not Clustered.

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料類型:intBase data type: int
IsFullTextInstalledIsFullTextInstalled 全文檢索和語意索引元件安裝在目前的 SQL ServerSQL Server 執行個體上。The full-text and semantic indexing components are installed on the current instance of SQL ServerSQL Server.

1 = 已安裝全文檢索和語意索引元件。1 = Full-text and semantic indexing components are installed.

0 = 未安裝全文檢索和語意索引元件。0 = Full-text and semantic indexing components are not installed.

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料類型:intBase data type: int
IsHadrEnabledIsHadrEnabled 適用對象SQL Server 2012 (11.x)SQL Server 2012 (11.x) 及更新版本。Applies to: SQL Server 2012 (11.x)SQL Server 2012 (11.x) and later.

在這個伺服器執行個體上已啟用 Always On 可用性群組Always On availability groupsAlways On 可用性群組Always On availability groups is enabled on this server instance.

0 = Always On 可用性群組Always On availability groups 功能已停用。0 = The Always On 可用性群組Always On availability groups feature is disabled.

1 = Always On 可用性群組Always On availability groups 功能已啟用。1 = The Always On 可用性群組Always On availability groups feature is enabled.

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料類型:intBase data type: int

若要在 SQL ServerSQL Server 的執行個體上建立及執行可用性複本,必須在此伺服器執行個體上啟用 Always On 可用性群組Always On availability groupsFor availability replicas to be created and run on an instance of SQL ServerSQL Server, Always On 可用性群組Always On availability groups must be enabled on the server instance. 如需詳細資訊,請參閱啟用和停用 AlwaysOn 可用性群組 (SQL Server)For more information, see Enable and Disable AlwaysOn Availability Groups (SQL Server).

注意: IsHadrEnabled 屬性只與 Always On 可用性群組Always On availability groups 相關。Note: The IsHadrEnabled property pertains only to Always On 可用性群組Always On availability groups. 此伺服器屬性不影響其他高可用性或災害復原功能,例如資料庫鏡像或記錄傳送。Other high availability or disaster recovery features, such as database mirroring or log shipping, are unaffected by this server property.
IsIntegratedSecurityOnlyIsIntegratedSecurityOnly 伺服器處於整合式安全性模式。Server is in integrated security mode.

1 = 整合式安全性 (Windows 驗證)1 = Integrated security (Windows Authentication)

0 = 非整合式安全性。0 = Not integrated security. (Windows 驗證及 SQL ServerSQL Server 驗證)。(Both Windows Authentication and SQL ServerSQL Server Authentication.)

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料類型:intBase data type: int
IsLocalDBIsLocalDB 適用對象SQL Server 2012 (11.x)SQL Server 2012 (11.x) 及更新版本。Applies to: SQL Server 2012 (11.x)SQL Server 2012 (11.x) and later.

伺服器是 SQL Server ExpressSQL Server Express LocalDB 的執行個體。Server is an instance of SQL Server ExpressSQL Server Express LocalDB.

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料類型:intBase data type: int
IsPolyBaseInstalledIsPolyBaseInstalled 適用於SQL Server 2016 (13.x)SQL Server 2016 (13.x)Applies to: SQL Server 2016 (13.x)SQL Server 2016 (13.x).

傳回伺服器執行個體是否已安裝 PolyBase 功能。Returns whether the server instance has the PolyBase feature installed.

0 = 未安裝 PolyBase。0 = PolyBase is not installed.

1 = 已安裝 PolyBase。1 = PolyBase is installed.

基底資料類型:intBase data type: int
IsSingleUserIsSingleUser 伺服器處於單一使用者模式。Server is in single-user mode.

1 = 單一使用者。1 = Single user.

0 = 非單一使用者0 = Not single user

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料類型:intBase data type: int
IsTempDbMetadataMemoryOptimizedIsTempDbMetadataMemoryOptimized 適用對象SQL Server 2019 (15.x)SQL Server 2019 (15.x) 及更新版本。Applies to: SQL Server 2019 (15.x)SQL Server 2019 (15.x) and later.

如果已啟用 tempdb 以為中繼資料使用經記憶體最佳化的資料表,則傳回 1;如果 tempdb 為中繼資料使用標準的磁碟型資料表,則傳回 0。Returns 1 if tempdb has been enabled to use memory-optimized tables for metadata; 0 if tempdb is using regular, disk-based tables for metadata. 如需詳細資訊,請參閱 tempdb DatabaseFor more information, see tempdb Database.

基底資料類型:intBase data type: int
IsXTPSupportedIsXTPSupported 適用於:SQL Server (SQL Server 2014 (12.x)SQL Server 2014 (12.x) 及更新版本)、SQL DatabaseSQL DatabaseApplies to: SQL Server (SQL Server 2014 (12.x)SQL Server 2014 (12.x) and later), SQL DatabaseSQL Database.

伺服器支援 In-Memory OLTP。Server supports In-Memory OLTP.

1= 伺服器支援 In-Memory OLTP。1= Server supports In-Memory OLTP.

0= 伺服器不支援 In-Memory OLTP。0= Server does not supports In-Memory OLTP.

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料類型:intBase data type: int
LCIDLCID Windows 的定序地區設定識別碼 (LCID)。Windows locale identifier (LCID) of the collation.

基底資料類型:intBase data type: int
LicenseTypeLicenseType 未使用的。Unused. SQL ServerSQL Server 產品未保留或維護的授權資訊。License information is not preserved or maintained by the SQL ServerSQL Server product. 一律傳回 DISABLED。Always returns DISABLED.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
MachineNameMachineName 執行伺服器執行個體的 Windows 電腦名稱。Windows computer name on which the server instance is running.

如果是叢集執行個體,也就是在 Microsoft Cluster Service 虛擬伺服器上執行的 SQL ServerSQL Server 執行個體,便會傳回虛擬伺服器名稱。For a clustered instance, an instance of SQL ServerSQL Server running on a virtual server on Microsoft Cluster Service, it returns the name of the virtual server.

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
NumLicensesNumLicenses 未使用的。Unused. SQL ServerSQL Server 產品未保留或維護的授權資訊。License information is not preserved or maintained by the SQL ServerSQL Server product. 一律傳回 NULL。Always returns NULL.

基底資料類型:intBase data type: int
ProcessIDProcessID SQL ServerSQL Server 服務的處理序識別碼。Process ID of the SQL ServerSQL Server service. 在識別哪個 Sqlservr.exe 屬於這個執行個體時,ProcessID 非常有用。ProcessID is useful in identifying which Sqlservr.exe belongs to this instance.

NULL = 輸入無效、發生錯誤或不適用。NULL = Input is not valid, an error, or not applicable.

基底資料類型:intBase data type: int
ProductBuildProductBuild 適用對象SQL Server 2014 (12.x)SQL Server 2014 (12.x) (自 2015 年 10 月開始)。Applies to: SQL Server 2014 (12.x)SQL Server 2014 (12.x) beginning October, 2015.

組建編號。The build number.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
ProductBuildTypeProductBuildType 適用對象SQL Server 2012 (11.x)SQL Server 2012 (11.x) 至目前版本 (從 2015 晚期開始的更新)。Applies to: SQL Server 2012 (11.x)SQL Server 2012 (11.x) through current version in updates beginning in late 2015.

目前組建的組建類型。Type of build of the current build.

傳回下列項目之一:Returns one of the following:

OD = 特定客戶的隨選版本。OD = On Demand release a specific customer.

GDR = 透過 Windows Update 發行的一般發行版本。GDR = General Distribution Release released through windows update.

NULL = 不適用。NULL = Not applicable.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
ProductLevelProductLevel SQL ServerSQL Server 執行個體的版本層級。Level of the version of the instance of SQL ServerSQL Server.

傳回下列項目之一:Returns one of the following:

'RTM' = 原始發行版本'RTM' = Original release version

'SP n' = Service Pack 版本'SP n' = Service pack version

'CTP n', = Community Technical Preview 版本'CTP n', = Community Technology Preview version

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
ProductMajorVersionProductMajorVersion 適用對象SQL Server 2012 (11.x)SQL Server 2012 (11.x) 至目前版本 (從 2015 晚期開始的更新)。Applies to: SQL Server 2012 (11.x)SQL Server 2012 (11.x) through current version in updates beginning in late 2015.

主要版本。The major version.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
ProductMinorVersionProductMinorVersion 適用對象SQL Server 2012 (11.x)SQL Server 2012 (11.x) 至目前版本 (從 2015 晚期開始的更新)。Applies to: SQL Server 2012 (11.x)SQL Server 2012 (11.x) through current version in updates beginning in late 2015.

次要版本。The minor version.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
ProductUpdateLevelProductUpdateLevel 適用對象SQL Server 2012 (11.x)SQL Server 2012 (11.x) 至目前版本 (從 2015 晚期開始的更新)。Applies to: SQL Server 2012 (11.x)SQL Server 2012 (11.x) through current version in updates beginning in late 2015.

目前組建的更新層級。Update level of the current build. CU 表示累積更新。CU indicates a cumulative update.

傳回下列項目之一:Returns one of the following:

CU n = 累積更新CU n = Cumulative Update

NULL = 不適用。NULL = Not applicable.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
ProductUpdateReferenceProductUpdateReference 適用對象SQL Server 2012 (11.x)SQL Server 2012 (11.x) 至目前版本 (從 2015 晚期開始的更新)。Applies to: SQL Server 2012 (11.x)SQL Server 2012 (11.x) through current version in updates beginning in late 2015.

該版本的知識庫文章。KB article for that release.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
ProductVersionProductVersion SQL ServerSQL Server 執行個體的版本,格式為 'major.minor.build.revision'。Version of the instance of SQL ServerSQL Server, in the form of 'major.minor.build.revision'.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
ResourceLastUpdateDateTimeResourceLastUpdateDateTime 傳回資源資料庫上次更新的日期和時間。Returns the date and time that the Resource database was last updated.

基底資料型別:datetimeBase data type: datetime
ResourceVersionResourceVersion 傳回版本資源資料庫。Returns the version Resource database.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
ServerNameServerName 指定的 SQL ServerSQL Server 執行個體所關聯的 Windows 伺服器和執行個體資訊。Both the Windows server and instance information associated with a specified instance of SQL ServerSQL Server.

NULL = 輸入無效,或發生錯誤。NULL = Input is not valid, or an error.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
SqlCharSetSqlCharSet 定序識別碼中的 SQL 字元集識別碼。The SQL character set ID from the collation ID.

基底資料型別:tinyintBase data type: tinyint
SqlCharSetNameSqlCharSetName 定序中的 SQL 字元集名稱。The SQL character set name from the collation.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)
SqlSortOrderSqlSortOrder 定序中的 SQL 排序順序識別碼The SQL sort order ID from the collation

基底資料型別:tinyintBase data type: tinyint
SqlSortOrderNameSqlSortOrderName 定序中的 SQL 排序次序名稱。The SQL sort order name from the collation.

基底資料型別:nvarchar(128)Base data type: nvarchar(128)

傳回型別Return Types

sql_variantsql_variant

備註Remarks

ServerName 屬性ServerName Property

SERVERPROPERTY 函式的 ServerName 屬性及 @@SERVERNAME 會傳回類似的資訊。The ServerName property of the SERVERPROPERTY function and @@SERVERNAME return similar information. ServerName 屬性提供共同組成唯一伺服器執行個體的 Windows 伺服器和執行個體名稱。The ServerName property provides the Windows server and instance name that together make up the unique server instance. @@SERVERNAME 提供目前設定的本機伺服器名稱。@@SERVERNAME provides the currently configured local server name.

如果安裝時的預設伺服器名稱沒有變更,ServerName 屬性和 @@SERVERNAME 會傳回相同的資訊。The ServerName property and @@SERVERNAME return the same information if the default server name at the time of installation has not been changed. 您可以執行下列作業來設定本機伺服器名稱:The local server name can be configured by executing the following:

EXEC sp_dropserver 'current_server_name';  
GO  
EXEC sp_addserver 'new_server_name', 'local';  
GO  

如果本機伺服器名稱已變更為不是安裝時的預設伺服器名稱,@@SERVERNAME 就會傳回新的名稱。If the local server name has been changed from the default server name at installation time, @@SERVERNAME returns the new name.

Version 屬性Version Properties

SERVERPROPERTY 函式會傳回與版本資訊相關的個別屬性,而 @@VERSION 函式則會將輸出結合成一個字串。The SERVERPROPERTY function returns individual properties that relate to the version information whereas the @@VERSION function combines the output into one string. 若您的應用程式需要個別屬性字串,您可以使用 SERVERPROPERTY 函式傳回它們,而非剖析 @@VERSION 的結果。If your application requires individual property strings, you can use the SERVERPROPERTY function to return them instead of parsing the @@VERSION results.

權限Permissions

所有使用者都可以查詢伺服器屬性。All users can query the server properties.

範例Examples

下列範例會使用 SELECT 陳述式中的 SERVERPROPERTY 函式來傳回目前 SQL ServerSQL Server 執行個體的相關資訊。The following example uses the SERVERPROPERTY function in a SELECT statement to return information about the current instance of SQL ServerSQL Server.

SELECT  
  SERVERPROPERTY('MachineName') AS ComputerName,
  SERVERPROPERTY('ServerName') AS InstanceName,  
  SERVERPROPERTY('Edition') AS Edition,
  SERVERPROPERTY('ProductVersion') AS ProductVersion,  
  SERVERPROPERTY('ProductLevel') AS ProductLevel;  
GO  

另請參閱See Also

SQL Server 2016 的版本和元件Editions and Components of SQL Server 2016