Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically detect SQL Server Edition

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!

like image 868
reustmd Avatar asked Mar 02 '09 15:03

reustmd


People also ask

What is the best way to find the SQL services in a server via PowerShell?

Get-Service is PowerShell cmdlet that lists all the registered Windows services either from a local or a remote server. The output lists the SQL instances of the remote machines. This is because every instance also runs a corresponding service.


1 Answers

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

like image 172
Patrick McDonald Avatar answered Sep 21 '22 06:09

Patrick McDonald