Programmatically detect SQL Server Edition Programmatically detect SQL Server Edition sql-server sql-server

Programmatically detect SQL Server Edition


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


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.


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.