Programmatically detect SQL Server Edition

前端 未结 5 1238
-上瘾入骨i
-上瘾入骨i 2021-01-05 00:43

I\'m using C# with SMO and attempting to detect what edition of SQL Server (e.g., enterprise, standard) I\'m connecting to. I know how to get the version information, but t

相关标签:
5条回答
  • 2021-01-05 01:08

    It looks like you might be able to do it via SMO and the Server object. There are properties like Information.Edition which looks like it should do what you want.

    0 讨论(0)
  • 2021-01-05 01:12
    select @@version
    

    Returns version and which edition. Here:

    Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86) 
        Nov 24 2008 13:01:59 
        Copyright (c) 1988-2005 Microsoft Corporation
        Developer Edition on Windows NT 5.2 (Build 3790: Service Pack 2)
    
    0 讨论(0)
  • 2021-01-05 01:20

    Check the registry. This question had a good method you could adapt from the PowerShell script:

    How do I check for the SQL Server Version using Powershell?

    0 讨论(0)
  • 2021-01-05 01:21
    SELECT  SERVERPROPERTY('productversion'), 
            SERVERPROPERTY ('productlevel'), 
            SERVERPROPERTY ('edition')
    

    on my system returns

    9.00.1399.06, RTM, Express Edition
    

    It seems this technique only works on SQL Server 2000 or later, if any of your databases are 7.0 or less, you'll have to use @@Version and manipulate the results as others have posted

    0 讨论(0)
  • 2021-01-05 01:22

    I've always used @@Version (eg. SELECT @@Version and manipluted the result in code), but this article looks pretty handy; http://support.microsoft.com/kb/321185

    The only issue with using SERVERPROPERTY, as per the link... is that this won't work with older version of SQL Server.

    0 讨论(0)
提交回复
热议问题