Programmatically detect SQL Server Edition
Asked Answered
B

5

8

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 that only tells me what version of SQL Server (e.g., SQL Server 2008 vs SQL Server 2005).

Does anyone know how to get the actual product edition (e.g., enterprise, standard)?

I need this information because some SQL Server features are only enterprise. Thus, I could just try to call them and catch the exception, but I'd much prefer an upfront detection.

Thanks!

Bemis answered 2/3, 2009 at 15:10 Comment(0)
F
6

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.

Flagg answered 2/3, 2009 at 15:22 Comment(1)
I appreciate all the answers that included @@Version, but I was really looking for something like this. The Information.Edition property on the Serverobject is what I need (though I which it was an enum and not a string).Bemis
S
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

Sebastian answered 2/3, 2009 at 15:19 Comment(0)
F
6

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.

Flagg answered 2/3, 2009 at 15:22 Comment(1)
I appreciate all the answers that included @@Version, but I was really looking for something like this. The Information.Edition property on the Serverobject is what I need (though I which it was an enum and not a string).Bemis
E
4

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.

Exhilarant answered 2/3, 2009 at 15:15 Comment(0)
V
3
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)
Val answered 2/3, 2009 at 15:15 Comment(0)
T
0

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?

Turkic answered 21/10, 2016 at 11:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.