Including a named instance of SQL Server 2008 Express with my application

Good morning everyone. This is my first stackoverflow question, so hopefully this is not something that was beaten to death and I could not find it.

I am developing an application that will be distributed using compression. We got the rights to distribute SQL Server 2008 Express Edition with our application, but HOW to do this is a little more complicated. Right now we are using the standard Visual Studio installation project, and I obviously hoped for something very simple, like a configurable merge module, but obviously there isn’t such a thing or I wouldn’t publish it here;)

The road I started to decline was to enable the self-extracting EXE with our package, and then use a special installation action to extract it and pass command-line arguments to the SQL installer to create our named instance. Here is where the problem arises.

The extraction is beautiful. I can run the script from Windows, and it installs SQL Server as it should, but I can not start the SQL installer from its user action, because it says that another installation is already in progress. This other installation is, of course, my application, and it will not end until SQL Server is finished, so we essentially stalled until SQL finally gave up and worked.

What I WANT is a named instance of the SQL server for my application, which is installed with it and which will be deleted with it. Writing your own installer is not an option because of the time, and my colleague says InstallShield is not an option because of the complexity (I never used it, so I'll take his word for it). Anyone have any thoughts?

+4
source share
5 answers

I am going to go further and answer my question for the sake of someone else who is looking for such information about SO ... from all that I could say, it is simply not possible to install a special instance of SQL Server (2008 anyway and, possibly 2005), which is associated with the installation of user software without going along the path to both the boot loader and a third-party installation product (InstallShield, etc.). It looks like the version of SQL Server Compact might be better suited.

+1
source

We encountered a similar problem when we tried to deploy a named instance of SQL 2008 Express R2 with our shrink applicator. We really work by creating a custom bootloader. Below are copies of posts from our wiki that describe this, hopefully they will be helpful to others trying to do this.

It is important to note that in VS2012 / 2013 we still have to decide how to do this work with InstallShield LE (ISLE), so if you are making this decision now and plan to upgrade VS, then this is probably not worth finding a solution. which will work in ISLE.

SQL 2008 R2 Bootstrapper Prerequisite for Use in Installation Projects

From a line in VS2010, it is not possible to install SQL2008 Express R2 as a prerequisite for an installation project. The reason this is not possible is because there is no “boot device” for R2, only for 2008 Express. In addition, MS does not plan to add a bootloader for R2, since VS simply receives boot files for any version of SQL when this version of VS was released (R2 was released after VS2010).

Since there is no MS boot buffer for SQL 2008 R2, you need to create your own according to this article:

http://robindotnet.wordpress.com/2011/02/06/how-about-a-bootstrapper-package-for-sqlserver-express-2008-r2/

This boot script either creates an SQLEXPRESS instance if an older instance with this name does not exist, or upgrades an earlier instance named SQLEXPRESS to SQL Express 2008 R2.

NB: Changing the name of the SQL instance CANNOT be done with this, because the sqlversionchk.exe program used by the xml file is programmed to check only the SQLEXPRESS instance, and there is no way to pass its alternate name. We solved this problem by creating a new version of the above files that do not use sqlversionchk exe, but instead use the reg check to determine if SQL is installed, and if so, which version:

SQL 2008 R2 Named Instance of Bootstrapping

Purpose: Use the appropriate project setup for the VS Setup project (i.e., note that 2008 R2 is a prerequisite in the project prerequisites), and then install the installation project or upgrade your own named instance of SQL Server.

Success: we created a custom boot script for our version of the SQL application; it generally eliminates the SQLVersionCh.exe program.

What have we done:

We started with the robindotnet custom boot buffer as described above.

Then we removed all references to sqlversionchk.exe and replaced them with registry checks for what the current version of sql is. It is not as complicated as sqlversionchk, as it also checks if the SQL instance is suitable in the correct language and there are many conditions, if version x sql is currently installed, then it cannot be updated. however, for our purposes, this does not matter, since we control the instance (since it is a custom instance, not the default SQLEXPRESS instance), so we will know what versions it may be, and therefore we can check these versions.

Then, the bootloader works by simply checking the following four scenarios, of which only one should ever be true (i.e. four scenarios must be mutually exclusive)

Scenario 1: Platform: x86
Registry check: there is no registry value for our instance name Action: nothing in the registry, so SQL is not installed, if it is an x86 machine, install SQL

Scenario 2: Platform: x86
Registry Check: The registry value is not equal to the latest version of SQL that we use. Act. Update our existing custom instance with the name of the SQL instance being used.

This logic is theoretically erroneous if the installed version of SQL was a later version than the ones we are trying to install (since we will upgrade to an earlier version, which will fail), but this will never happen if the user decides to manually update our SQL instance that is uncontrollable.

Scenario 3: Platform: amd64 (note this does not mean that it is an amd machine, it is just a 64-bit installation of Windows)
Registry Check: There is no registry value for our instance name
Action: nothing in the registry, so SQL is not installed if it is a 64-bit SQL computer installation

Scenario 4: Platform: amd64
Registry Validation: The registry value does not match the latest version of SQL that we use. Action: Upgrade the existing custom named instance to the version of SQL we are currently using.

The complete boot file is described in detail at the end of this post.

How this custom bootloader will change in the future

We can check any version numbers that we like in the registry and determine which version is installed. Then we can control the execution. For example, if you need to upgrade to 2008 R2 before you can upgrade it to 2010, we can do this using the bypassIf construct and simply enter more options in the table above.

Our version of the bootloader:

Note that the name of the custom instance is "MVXBM"

<?xml version="1.0" encoding="utf-8" ?> <Package xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" Name="DisplayName" Culture="Culture" LicenseAgreement="eula.rtf"> <PackageFiles CopyAllPackageFiles="false"> <PackageFile Name="SQLEXPR32_x86_ENU.EXE" HomeSite="SqlExpr32Exe"/> <PackageFile Name="SQLEXPR_x64_ENU.EXE" HomeSite="SqlExpr64Exe"/> <PackageFile Name="eula.rtf"/> </PackageFiles> <InstallChecks> <RegistryCheck Property="SQLVersion" Key="HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\MVXBM\MSSQLServer\CurrentVersion" Value="CurrentVersion" /> </InstallChecks> <Commands Reboot="Defer"> <!-- Defines a new installation (x86) --> <Command PackageFile="SQLEXPR32_x86_ENU.EXE" Arguments='/q /hideconsole /action=Install /features=SQL /instancename=MVXBM /enableranu=1 /sqlsvcaccount="NT Authority\Network Service" /AddCurrentUserAsSqlAdmin /skiprules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms' EstimatedInstalledBytes="225000000" EstimatedInstallSeconds="420"> <InstallConditions> <FailIf Property="VersionNT" Compare="ValueNotExists" String="GeneralFailure"/> <FailIf Property="VersionNT" Compare="VersionLessThan" Value="5.1.2" String="InvalidPlatformXP"/> <FailIf Property="VersionNT" Compare="VersionEqualTo" Value="5.2.0" String="InvalidPlatform2K3"/> <FailIf Property="VersionNT" Compare="VersionEqualTo" Value="5.2.1" String="InvalidPlatform2K3"/> <FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/> <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="Intel"/> <BypassIf Property="SQLVersion" Compare="ValueExists"/> </InstallConditions> <ExitCodes> <ExitCode Value="0" Result="Success"/> <ExitCode Value="1641" Result="SuccessReboot"/> <ExitCode Value="3010" Result="SuccessReboot"/> <!-- 0x84BE0BC2 (1214,3010) --> <ExitCode Value="-2067919934" Result="FailReboot"/> <!-- 0x84C10BC2 (1217,3010) --> <ExitCode Value="-2067723326" Result="FailReboot"/> <!-- 0x84BE0007 (1214,7) --> <ExitCode Value="-2067922937" Result="Fail" String="AdminRequired"/> <!-- 0x84C4001F (1220,31) --> <ExitCode Value="-2067529697" Result="Fail" String="AdminRequired"/> <!-- 0x84BE0001 (1214,1)--> <ExitCode Value="-2067922943" Result="Fail" String="InvalidPlatformOSServicePacks"/> <!-- 0x84C4000B (1220,11) --> <ExitCode Value="-2067529717" Result="Fail" String="AnotherInstanceRunning"/> <!-- 0x84BE01F8 (1214,504) --> <ExitCode Value="-2067922440" Result="Fail" String="BetaComponentsFailure"/> <!-- 0x84BE01FA (1214,506) --> <ExitCode Value="-2067922438" Result="Fail" String="BetaComponentsFailure"/> <!-- 0x84BE0202 (1214,514) --> <ExitCode Value="-2067922430" Result="Fail" String="InvalidPlatformArchitecture"/> <!-- 0x84BE0203 (1214,515) --> <ExitCode Value="-2067922429" Result="Fail" String="InvalidPlatformArchitecture"/> <ExitCode Value="216" Result="Fail" String="InvalidPlatformArchitecture"/> <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" /> </ExitCodes> </Command> <!-- Defines an upgrade installation (x86) --> <Command PackageFile="SQLEXPR32_x86_ENU.EXE" Arguments="/q /hideconsole /action=Upgrade /instancename=MVXBM /skiprules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms" EstimatedInstalledBytes="225000000" EstimatedInstallSeconds="420"> <InstallConditions> <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="Intel"/> <BypassIf Property="SQLVersion" Compare="ValueNotExists"/> <BypassIf Property="SQLVersion" Compare="ValueEqualTo" Value="10.50.1600.1"/> </InstallConditions> <ExitCodes> <ExitCode Value="0" Result="Success"/> <ExitCode Value="1641" Result="SuccessReboot"/> <ExitCode Value="3010" Result="SuccessReboot"/> <!-- 0x84BE0BC2 (1214,3010) --> <ExitCode Value="-2067919934" Result="FailReboot"/> <!-- 0x84C10BC2 (1217,3010) --> <ExitCode Value="-2067723326" Result="FailReboot"/> <!-- 0x84BE0007 (1214,7) --> <ExitCode Value="-2067922937" Result="Fail" String="AdminRequired"/> <!-- 0x84C4001F (1220,31) --> <ExitCode Value="-2067529697" Result="Fail" String="AdminRequired"/> <!-- 0x84BE0001 (1214,1)--> <ExitCode Value="-2067922943" Result="Fail" String="InvalidPlatformOSServicePacks"/> <!-- 0x84C4000B (1220,11) --> <ExitCode Value="-2067529717" Result="Fail" String="AnotherInstanceRunning"/> <!-- 0x84BE01F8 (1214,504) --> <ExitCode Value="-2067922440" Result="Fail" String="BetaComponentsFailure"/> <!-- 0x84BE01FA (1214,506) --> <ExitCode Value="-2067922438" Result="Fail" String="BetaComponentsFailure"/> <!-- 0x84BE0202 (1214,514) --> <ExitCode Value="-2067922430" Result="Fail" String="InvalidPlatformArchitecture"/> <!-- 0x84BE0203 (1214,515) --> <ExitCode Value="-2067922429" Result="Fail" String="InvalidPlatformArchitecture"/> <ExitCode Value="216" Result="Fail" String="InvalidPlatformArchitecture"/> <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" /> </ExitCodes> </Command> <!-- Defines a new installation (amd64) --> <Command PackageFile="SQLEXPR_x64_ENU.EXE" Arguments='/q /hideconsole /action=Install /features=SQL /instancename=MVXBM /enableranu=1 /sqlsvcaccount="NT Authority\Network Service" /AddCurrentUserAsSqlAdmin /skiprules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms' EstimatedInstalledBytes="225000000" EstimatedInstallSeconds="420"> <InstallConditions> <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="amd64"/> <BypassIf Property="SQLVersion" Compare="ValueExists"/> </InstallConditions> <ExitCodes> <ExitCode Value="0" Result="Success"/> <ExitCode Value="1641" Result="SuccessReboot"/> <ExitCode Value="3010" Result="SuccessReboot"/> <!-- 0x84BE0BC2 (1214,3010) --> <ExitCode Value="-2067919934" Result="FailReboot"/> <!-- 0x84C10BC2 (1217,3010) --> <ExitCode Value="-2067723326" Result="FailReboot"/> <!-- 0x84BE0007 (1214,7) --> <ExitCode Value="-2067922937" Result="Fail" String="AdminRequired"/> <!-- 0x84C4001F (1220,31) --> <ExitCode Value="-2067529697" Result="Fail" String="AdminRequired"/> <!-- 0x84BE0001 (1214,1)--> <ExitCode Value="-2067922943" Result="Fail" String="InvalidPlatformOSServicePacks"/> <!-- 0x84C4000B (1220,11) --> <ExitCode Value="-2067529717" Result="Fail" String="AnotherInstanceRunning"/> <!-- 0x84BE01F8 (1214,504) --> <ExitCode Value="-2067922440" Result="Fail" String="BetaComponentsFailure"/> <!-- 0x84BE01FA (1214,506) --> <ExitCode Value="-2067922438" Result="Fail" String="BetaComponentsFailure"/> <!-- 0x84BE0202 (1214,514) --> <ExitCode Value="-2067922430" Result="Fail" String="InvalidPlatformArchitecture"/> <!-- 0x84BE0203 (1214,515) --> <ExitCode Value="-2067922429" Result="Fail" String="InvalidPlatformArchitecture"/> <ExitCode Value="216" Result="Fail" String="InvalidPlatformArchitecture"/> <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" /> </ExitCodes> </Command> <!-- Defines an upgrade installation (amd64) --> <Command PackageFile="SQLEXPR_x64_ENU.EXE" Arguments="/q /hideconsole /action=Upgrade /instancename=MVXBM /skiprules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms" EstimatedInstalledBytes="225000000" EstimatedInstallSeconds="420"> <InstallConditions> <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="amd64"/> <BypassIf Property="SQLVersion" Compare="ValueNotExists"/> <BypassIf Property="SQLVersion" Compare="ValueEqualTo" Value="10.50.1600.1"/> </InstallConditions> <ExitCodes> <ExitCode Value="0" Result="Success"/> <ExitCode Value="1641" Result="SuccessReboot"/> <ExitCode Value="3010" Result="SuccessReboot"/> <!-- 0x84BE0BC2 (1214,3010) --> <ExitCode Value="-2067919934" Result="FailReboot"/> <!-- 0x84C10BC2 (1217,3010) --> <ExitCode Value="-2067723326" Result="FailReboot"/> <!-- 0x84BE0007 (1214,7) --> <ExitCode Value="-2067922937" Result="Fail" String="AdminRequired"/> <!-- 0x84C4001F (1220,31) --> <ExitCode Value="-2067529697" Result="Fail" String="AdminRequired"/> <!-- 0x84BE0001 (1214,1)--> <ExitCode Value="-2067922943" Result="Fail" String="InvalidPlatformOSServicePacks"/> <!-- 0x84C4000B (1220,11) --> <ExitCode Value="-2067529717" Result="Fail" String="AnotherInstanceRunning"/> <!-- 0x84BE01F8 (1214,504) --> <ExitCode Value="-2067922440" Result="Fail" String="BetaComponentsFailure"/> <!-- 0x84BE01FA (1214,506) --> <ExitCode Value="-2067922438" Result="Fail" String="BetaComponentsFailure"/> <!-- 0x84BE0202 (1214,514) --> <ExitCode Value="-2067922430" Result="Fail" String="InvalidPlatformArchitecture"/> <!-- 0x84BE0203 (1214,515) --> <ExitCode Value="-2067922429" Result="Fail" String="InvalidPlatformArchitecture"/> <ExitCode Value="216" Result="Fail" String="InvalidPlatformArchitecture"/> <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" /> </ExitCodes> </Command> </Commands> <Strings> <String Name="DisplayName">SQL Server 2008 R2 Express - MVXBM</String> <String Name="Culture">en</String> <String Name="SqlExpr32Exe">http://download.microsoft.com/download/5/1/a/51a153f6-6b08-4f94-a7b2-ba1ad482bc75/SQLEXPR32_x86_ENU.exe</String> <String Name="SqlExpr64Exe">http://download.microsoft.com/download/5/1/a/51a153f6-6b08-4f94-a7b2-ba1ad482bc75/SQLEXPR_x64_ENU.exe</String> <String Name="AdminRequired">You do not have the permissions required to install SQL Server 2008 R2 Express. Please contact your administrator.</String> <String Name="GeneralFailure">An error occurred attempting to install SQL Server 2008 R2 Express.</String> <String Name="InvalidPlatformXP">Windows XP Service Pack 2 or later is required to install SQL Server 2008 R2 Express.</String> <String Name="InvalidPlatform2K3">Windows 2003 Service Pack 2 or later is required to install SQL Server 2008 R2 Express.</String> <String Name="MissingMSXml">SQL Server 2008 R2 Express requires MSXML. Please ensure MSXML is installed properly.</String> <String Name="InsufficientHardware">The current system does not meet the minimum hardware requirements for SQL Server 2008 R2 Express. Contact your application vendor.</String> <String Name="InvalidPlatformOSServicePacks">The current operating system does not meet Service Pack level requirements for SQL Server 2008 R2 Express. Install the most recent Service Pack from the Microsoft download center at http://www.microsoft.com/downloads before continuing setup.</String> <String Name="InvalidPlatformIE">This version of SQL Server 2008 R2 Express requires Internet Explorer version 6.0 with SP1 or later. To proceed, install or upgrade to a required version of Internet Explorer and then run setup again.</String> <String Name="AnotherInstanceRunning">Another instance of setup is already running. The running instance must complete before this setup can proceed.</String> <String Name="BetaComponentsFailure">A beta version of the .NET Framework 2.0 or SQL Server was detected on the computer. Uninstall any previous beta versions of SQL Server 2008 R2 components, SQL Server Support Files, or .NET Framework 2.0 before continuing.</String> <String Name="InvalidPlatformArchitecture">This version of SQL Server 2008 R2 Express is not supported for the current processor architecture.</String> <String Name="InvalidUpgradeNotExpress">The instance of SQL Server 2005 named 'SQLEXPRESS' is a not an instance of SQL Server Express. It cannot be upgraded to SQL Server 2008 R2 Express.</String> <String Name="InvalidUpgradeNotExpressCore">The instance of SQL Server 2005 Express named 'SQLEXPRESS' contains components that are not included in SQL Server 2008 R2 Express. SQL Server 2008 R2 Express SP1 cannot upgrade this instance. Please use SQL Server 2008 R2 Express with Advanced Services instead.</String> <String Name="InvalidUpgradeLanguage">The instance of SQL Server 2005 Express named 'SQLEXPRESS' is a different language version than this SQL Server 2008 R2 Express. SQL Server 2008 R2 Express cannot upgrade this instance.</String> <String Name="InvalidUpgradeWoW">SQL Server 2008 R2 Express (x64) cannot upgrade the existing instance of SQL Server 2005 Express (x64 WoW) named 'SQLEXPRESS'. Uninstall this instance of SQL Server 2005 Express and retry installing SQL Server 2008 R2 Express (x64).</String> </Strings> </Package> 
+2
source

The code in this project is built for SQL2005, but it looks like it could be easily used to deploy SQL2008.

http://www.codeproject.com/KB/applications/NET_Installer_With_SQLEXP.aspx

It also supports the instance name of your choice. This will require some tuning, but it seems to support the main tenants of what you are trying to do.

+1
source

I don't know if everyone keeps track of this. Perhaps you can take a look at this:

http://msdn.microsoft.com/en-us/library/dd981032(SQL.100).aspx

Not tried, but I'm looking to solve the same problem posted by Adam.

+1
source

One approach is to enable the SQL Server 2008 Express installation package, and then use the custom action in your Windows installer to disable the silent background installation of SQL Server 2008 Express.

The package is a standard MSI package - you should be able to set the boat properties on the command line when installing MSI.

Here is the sample I found:

 sqlexpr.exe /qb instancename="MACHINENAMESQLEXPRESS2008" SQLAUTOSTART=1 SAPWD="PWD" SECURITYMODE=SQL DISABLENETWORKPROTOCOLS=0" 

A complete list of command line properties should be available in Microsoft or in the help file for SQL Server 2008 Express, I'm sure.

Mark

0
source

All Articles