如何验证SQL Server版本,包括版本,Service Pack,累积更新和修补程序

时间:2016-07-13 06:00:04

标签: sql sql-server powershell

对于使用不同版本的SQL服务器安装的不同客户端,我有250个VM。

我运行以下命令来获取详细信息,但信息不成功

SELECT 
    SERVERPROPERTY('productversion'), 
    SERVERPROPERTY('productlevel'),
    SERVERPROPERTY ('edition'),  
    @@version, 
    SERVERPROPERTY('PatchLevel')

有人可以帮忙吗?我需要有关SQL Server版本,Service Pack,累积更新和安装到服务器的补丁等详细信息。

2 个答案:

答案 0 :(得分:1)

希望你需要这个。,

select @@VERSION

希望这可以帮助你。

SELECT SERVERPROPERTY('MachineName') AS [MachineName], 
SERVERPROPERTY('ServerName') AS [ServerName],  
SERVERPROPERTY('InstanceName') AS [Instance], 
SERVERPROPERTY('IsClustered') AS [IsClustered], 
SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS [ComputerNamePhysicalNetBIOS], 
SERVERPROPERTY('Edition') AS [Edition], 
SERVERPROPERTY('ProductLevel') AS [ProductLevel],               -- What servicing branch (RTM/SP/CU)
SERVERPROPERTY('ProductUpdateLevel') AS [ProductUpdateLevel],   -- Within a servicing branch, what CU# is applied
SERVERPROPERTY('ProductVersion') AS [ProductVersion],
SERVERPROPERTY('ProductMajorVersion') AS [ProductMajorVersion], 
SERVERPROPERTY('ProductMinorVersion') AS [ProductMinorVersion], 
SERVERPROPERTY('ProductBuild') AS [ProductBuild], 
SERVERPROPERTY('ProductBuildType') AS [ProductBuildType],       -- Is this a GDR or OD hotfix (NULL if on a CU build)
SERVERPROPERTY('ProductUpdateReference') AS [ProductUpdateReference], -- KB article number that is applicable for this build
SERVERPROPERTY('ProcessID') AS [ProcessID],
SERVERPROPERTY('Collation') AS [Collation], 
SERVERPROPERTY('IsFullTextInstalled') AS [IsFullTextInstalled], 
SERVERPROPERTY('IsIntegratedSecurityOnly') AS [IsIntegratedSecurityOnly],
SERVERPROPERTY('FilestreamConfiguredLevel') AS [FilestreamConfiguredLevel],
SERVERPROPERTY('IsHadrEnabled') AS [IsHadrEnabled], 
SERVERPROPERTY('HadrManagerStatus') AS [HadrManagerStatus],
SERVERPROPERTY('InstanceDefaultDataPath') AS [InstanceDefaultDataPath],
SERVERPROPERTY('InstanceDefaultLogPath') AS [InstanceDefaultLogPath],
SERVERPROPERTY('BuildClrVersion') AS [Build CLR Version];

答案 1 :(得分:0)

这是一个查询,通过SERVERPROPERTY system function为您提供所有可用的服务器属性。

您可以在旧的SQL版本上运行它,如果当时不存在该属性,该函数将安全地返回NULL。

SELECT
     SERVERPROPERTY('BuildClrVersion') AS BuildClrVersion
    ,SERVERPROPERTY('Collation') AS [Collation]
    ,SERVERPROPERTY('CollationID') AS CollationID
    ,SERVERPROPERTY('ComparisonStyle') AS ComparisonStyle
    ,SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS [ComputerNamePhysicalNetBIOS]
    ,SERVERPROPERTY('Edition') AS [Edition]
    ,SERVERPROPERTY('EditionID') AS EditionID
    ,SERVERPROPERTY('EngineEdition') AS EngineEdition
    ,SERVERPROPERTY('FilestreamConfiguredLevel') AS FilestreamConfiguredLevel
    ,SERVERPROPERTY('FilestreamEffectiveLevel') AS FilestreamEffectiveLevel
    ,SERVERPROPERTY('FilestreamShareName') AS FilestreamShareName
    ,SERVERPROPERTY('HadrManagerStatus') AS HadrManagerStatus
    ,SERVERPROPERTY('InstanceDefaultDataPath') AS InstanceDefaultDataPath
    ,SERVERPROPERTY('InstanceDefaultLogPath') AS InstanceDefaultLogPath
    ,SERVERPROPERTY('InstanceName') AS [Instance]
    ,SERVERPROPERTY('IsAdvancedAnalyticsInstalled') AS IsAdvancedAnalyticsInstalled
    ,SERVERPROPERTY('IsClustered') AS [IsClustered]
    ,SERVERPROPERTY('IsFullTextInstalled') AS [IsFullTextInstalled]
    ,SERVERPROPERTY('IsHadrEnabled') AS IsHadrEnabled
    ,SERVERPROPERTY('IsIntegratedSecurityOnly') AS [IsIntegratedSecurityOnly]
    ,SERVERPROPERTY('IsLocalDB') AS IsLocalDB
    ,SERVERPROPERTY('IsPolybaseInstalled') AS IsPolybaseInstalled
    ,SERVERPROPERTY('IsSingleUser') AS IsSingleUser
    ,SERVERPROPERTY('IsXTPSupported') AS IsXTPSupported
    ,SERVERPROPERTY('LCID') AS LCID
    ,SERVERPROPERTY('LicenseType') AS LicenseType
    ,SERVERPROPERTY('MachineName') AS [MachineName]
    ,SERVERPROPERTY('ProcessID') AS [ProcessID]
    ,SERVERPROPERTY('ProductBuild') AS ProductBuild
    ,SERVERPROPERTY('ProductBuildType') AS ProductBuildType
    ,SERVERPROPERTY('ProductLevel') AS ProductLevel
    ,SERVERPROPERTY('ProductMajorVersion') AS ProductMajorVersion
    ,SERVERPROPERTY('ProductMinorVersion') AS ProductMinorVersion
    ,SERVERPROPERTY('ProductUpdateLevel') AS ProductUpdateLevel
    ,SERVERPROPERTY('ProductUpdateReference') AS ProductUpdateReference
    ,SERVERPROPERTY('ProductVersion') AS [ProductVersion]
    ,SERVERPROPERTY('ResourceLastUpdateDateTime') AS ResourceLastUpdateDateTime
    ,SERVERPROPERTY('ResourceVersion') AS ResourceVersion
    ,SERVERPROPERTY('ServerName') AS [ServerName]
    ,SERVERPROPERTY('SqlCharSet') AS SqlCharSet
    ,SERVERPROPERTY('SqlCharSetName') AS SqlCharSetName
    ,SERVERPROPERTY('SqlSortOrder') AS SqlSortOrder
    ,SERVERPROPERTY('SqlSortOrderName') AS SqlSortOrderName
    ,@@VERSION AS [Version]