View Full Version : SQL 2005 Express Named Instance Question

06-09-2006, 03:18 PM
Microsoft recomends you install a named instance of SQL 2005 Express with your application. The prerequisite that ships with InstallShield does not have a condition to check for a named instance (understandably since they do not know your instance name, although this might be information they could add to the Description field in the Properties tab).

Is checking for the named instance as easy as checking the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL" for a key value with the name of your instance? Well I guess this will tell you if that instance is installed, but it won't tell you which version and edition of SQL that instance is running under. For that I guess you would have to read Setup key for that instance of the database.

Does anyone have any recommendations or words of wisdom? Has anyone been able to do this with the prerequisite editor? I am thinking of using the Visual Studio 2005 bootstrapper since you can configure it with a custom condition.


06-12-2006, 06:00 PM
You should be able to use the CurrentVersion value name under the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Your Instance Name\MSSQLServer\CurrentVersion to check the version number of the instance of SQL Server.

Hope this helps.

06-12-2006, 06:28 PM
Looks like the main problem is I have to look up the instance in the key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL" before I can look up the SQL version in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Your Instance Name\MSSQLServer\CurrentVersion". Unfortunately there doesn't appear to be a way to do this in the InstallShield prerequisites editor. Do you know of a way to do this?

Thanks for the info,

06-12-2006, 06:57 PM
By the way, why do you need for the SQL Server 2005 Express prerequisite to check the version number and edition of an instance of SQL Server? My understanding is that you should not be able to install the same named instance with different versions or editions of SQL Server on a same machine. Am I wrong?

06-13-2006, 10:18 AM
If you need to upgrade a named instance to a newer version of SQL Server you need to know 1) Is the named instance installed on the PC 2) What version of SQL Server is the named instance using.

The upgrade of the named instance could just be from SQL 2005 Express to SQL 2005 Express SP1 or from MSDE to SQL 2005 Express or from SQL 2005 Express to SQL 2005 Standard. All the documentation I've read so far says that all of the scenarios are valid. I am still learning this though so I may have missed something.

The main thing I need to know if I install our own named instance of SQL 2005 Express is 1) Is SQL 2005 Express SP1 installed 2) Is our named instance installed. These would work fine for our initial installation (this is a new app that has not been released), but for the future I may need to know 1) Is our named instance installed 2) What version of SQL server is our named instance using (e.g. - Our named instance is already installed and using SQL 2005 Express SP1 and we need to upgrade our named instance with a new SQL 2005 Express service pack). I would like to do the second set of checks from the start, but I do not see a way to do that in the Prerequisite editor.


06-14-2006, 04:20 PM
Thanks for the info. In order for the Microsoft SQL Server 2005 Express prerequisite to launch the setup based on a version number of SQL Server installed, you should be able to use the 'Registry entry has a certain value' condition with the following values:

Registry key name: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Your Instance Name\MSSQLServer\CurrentVersion
Value name: Current Version
Value data: 9.00.1399.06
How do you want to compare the data: Less than

This condition also tests whether the named instance has already been installed. If it is not installed, the "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Your Instance Name\MSSQLServer\CurrentVersion" registry key does not exist, then the prerequisite will launch the setup as the codition is false. So you would not need to check "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL" to see if a named instance has already been installed.

To determine which edition of SQL Server that instance is running under, I cannot think of a way to accomplish the requirement using the prerequisite. The information is stored in the Edition value name under the "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.n\Setup". However, the MSSQL.n is an internal name which you need to look up from "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL" using the correspoding instance name. So I filed the work order #IOC-000051180 so we will take into consideration how InstallShield can support the requirement in a future release.


06-14-2006, 05:43 PM
I see what you are saying now. I initially thought Your Instance Name in the registry key you mention was referring to the internal SQL Server name.

One problem that I see is that the registry check you suggest does a string comparison not a version comparison. While that may work initially it is not very reliable. I already have a request to be able to do version comparisons of registry string values. I don't know if a work order was created, but I did make that request in a recent thread. This is one reason I am considering using the bootstrapper in Visual Studio 2005. Another reason is that the Visual Studio 2005 bootstrapper allows you to create custom conditions which I should be able to use to get the Edition. I would rather not have to create a custom condition, but that may be the best option at this point as far as I can determine.

I think the ability to create a property in a condition that can then be used to generate a key (or other string) that is checked in another condition would be a great addtion.

Thanks for the info!