In one of my project, first I need to check whether SQL Server is installed on the machine or not. I am doing this with the code shown here:
var sqlRegistry = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Microsoft SQL Server", true);
if (sqlRegistry == null)
{ }
else
{ }
But in the else
part, I need to know whether the installed SQL Server is "only" SQL Server Express, or a full SQL Server edition.
How will I go for this?
You can look at the installed instances in the registry key:
Software\Microsoft\Microsoft SQL Server\InstalledInstances
This will contain all the installed instances, e.g. on my system:
MSSQLSERVER
SQLEXPRESS
Go into this registry key with this value:
Software\Microsoft\Microsoft SQL Server\Instance Names\SQL
to get the actual instance name that you need in the next step.
Now if you go look at the registry key:
Software\Microsoft\Microsoft SQL Server\(InstanceName)\Setup\Edition
there you have a value of e.g. Express
for a SQL Server Express, or Developer Edition
or something else. That should tell you if you have Express
or another, "full" edition of SQL Server
SQL-Server seems to have a built-in function SERVERPROPERTY
, so you should be able to query the server via SQL, like:
SELECT SERVERPROPERTY('EngineEdition')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With