The release of SQL Server 2008 R2 Express is a very exciting news both for developers and consumers. Not only it is FREE but it now comes with 10GB database storage. That’s a lot of data for small to medium enterprises. With the same advanced database engine as the full version of SQL Server 2008, I myself as a developer, is confident in using this database engine in mission critical applications.
But when the time has arrived that we have to deploy the application using Visual Studio 2008 Setup and Deployment Project, there is no SQL 2008 R2 Express in the Prerequisites options! That was a very frustrating one since we like that the installation should be as smooth as clicking next, next, install and finish.
Here is the solution I came up.
1. Download the SQL Server 2008 R2 Express installation setup
Download the 32-bit installer http://go.microsoft.com/?linkid=9729742
Download the 64-bit installer http://go.microsoft.com/?linkid=9729743
2. Go to folder C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages. For 64 bit system, go to C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages

3. Under Packages foder, create a new folder SQLExpress2008R2.
4. Go to SQLExpress2008R2 folder and create a new file product.xml with the contents below. Download product.xml
<?xml version=”1.0″ encoding=”utf-8″?>
<!– SQL Express 2008 VS Bootstrapper : product.xml : Language neutral information –>
<Product xmlns=”http://schemas.microsoft.com/developer/2004/01/bootstrapper” ProductCode=”Microsoft.Sql.Server.Express.10.50″>
<RelatedProducts>
<EitherProducts>
<DependsOnProduct Code=”.NETFramework,Version=v4.0″ />
<DependsOnProduct Code=”Microsoft.Net.Framework.3.5.SP1″ />
</EitherProducts>
<DependsOnProduct Code=”Microsoft.Windows.Installer.4.5″ />
<IncludesProduct Code=”Microsoft.Sql.Server.Express.1.0″ />
<IncludesProduct Code=”Microsoft.Sql.Server.Express.9.2″ />
</RelatedProducts>
</Product>
5. Still in SQLExpress2008R2 folder, create a new folder named en.

6. Go to folder en. Create a file with name eula.rtf. I just put a word SQL 2008 in this file.
7. Create a file with name package.xml with the contents below. Download package.xml.
<?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” PublicKey=”3082010a0282010100bd3089fb4572a8536b9e894f0023c0bed41d3db1594038f373918226e696120053d91c820e3cce1dbbbdf7428d97d4fc381ae4b9f9e3ecd36103bfa0d3d6754d5c46a9ed5ef0d2e2695b1a73eab31c8d04cd2944a064592f1e985d6ec7ab18398265c4a7bcab758819ea87971426b37f2676a4d4383984e3b326d518f92be9d2c9165a5421f2978d878629fef4492ce68bf8043f7dcdcd9692860d7103e2d0fe0c4235ffd7b83fdd8e450a7df6d74bad5bf076721d77237d8935c41c5db250034b476d07a75588980680a681ad544ed881d6fabf42c031be550d99d553491230ebe5a5887c5ec47a5a148708b43769a0eb32248c08ebf9d414bae0fccdeaa4150203010001″/>
<PackageFile Name=”SQLEXPR_x64_ENU.EXE” HomeSite=”SqlExpr64Exe” PublicKey=”3082010a0282010100bd3089fb4572a8536b9e894f0023c0bed41d3db1594038f373918226e696120053d91c820e3cce1dbbbdf7428d97d4fc381ae4b9f9e3ecd36103bfa0d3d6754d5c46a9ed5ef0d2e2695b1a73eab31c8d04cd2944a064592f1e985d6ec7ab18398265c4a7bcab758819ea87971426b37f2676a4d4383984e3b326d518f92be9d2c9165a5421f2978d878629fef4492ce68bf8043f7dcdcd9692860d7103e2d0fe0c4235ffd7b83fdd8e450a7df6d74bad5bf076721d77237d8935c41c5db250034b476d07a75588980680a681ad544ed881d6fabf42c031be550d99d553491230ebe5a5887c5ec47a5a148708b43769a0eb32248c08ebf9d414bae0fccdeaa4150203010001″/>
<PackageFile Name=”eula.rtf”/> </PackageFiles>
<Commands Reboot=”Defer”>
<!– Defines a new installation (x86) –>
<Command PackageFile=”SQLEXPR32_x86_ENU.EXE” Arguments=’/Q /HideConsole /IAcceptSqlServerLicenseTerms /Action=Install /Features=SQLEngine,SSMS /InstanceName=SQLEXPRESS /EnableRANU=1 /sqlsvcaccount=”NT AUTHORITY\Network Service” /AGTSVCACCOUNT=”NT AUTHORITY\Network Service” /AddCurrentUserAsSqlAdmin /SqlSysAdminAccounts=”BUILTIN\ADMINISTRATORS” /SkipRules=RebootRequiredCheck /SecurityMode=SQL /SaPwd=mypassword /TcpEnabled=1′ 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”/>
</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 /IAcceptSqlServerLicenseTerms /Action=Install /Features=SQLEngine,SSMS /InstanceName=SQLEXPRESS /EnableRANU=1 /sqlsvcaccount=”NT AUTHORITY\Network Service” /AGTSVCACCOUNT=”NT AUTHORITY\Network Service” /AddCurrentUserAsSqlAdmin /SqlSysAdminAccounts=”BUILTIN\ADMINISTRATORS” /SkipRules=RebootRequiredCheck /SecurityMode=SQL /SaPwd=mypassword /TcpEnabled=1′ EstimatedInstalledBytes=”225000000″ EstimatedInstallSeconds=”420″> <InstallConditions> <BypassIf Property=”ProcessorArchitecture” Compare=”ValueNotEqualTo” Value=”Intel”/> </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 /IAcceptSqlServerLicenseTerms /Action=Install /Features=SQLEngine,SSMS /InstanceName=SQLEXPRESS /EnableRANU=1 /sqlsvcaccount=”NT AUTHORITY\Network Service” /AGTSVCACCOUNT=”NT AUTHORITY\Network Service” /AddCurrentUserAsSqlAdmin /SqlSysAdminAccounts=”BUILTIN\ADMINISTRATORS” /SkipRules=RebootRequiredCheck /SecurityMode=SQL /SaPwd=9476444B-1A8F-438b-BAA2-6D635FC2A99E /TcpEnabled=1′ EstimatedInstalledBytes=”225000000″ EstimatedInstallSeconds=”420″> <InstallConditions> <BypassIf Property=”ProcessorArchitecture” Compare=”ValueNotEqualTo” Value=”amd64″/> </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 /IAcceptSqlServerLicenseTerms /Action=Install /Features=SQLEngine,SSMS /InstanceName=SQLEXPRESS /EnableRANU=1 /sqlsvcaccount=”NT AUTHORITY\Network Service” /AGTSVCACCOUNT=”NT AUTHORITY\Network Service” /AddCurrentUserAsSqlAdmin /SqlSysAdminAccounts=”BUILTIN\ADMINISTRATORS” /SkipRules=RebootRequiredCheck /SecurityMode=SQL /SaPwd=9476444B-1A8F-438b-BAA2-6D635FC2A99E /TcpEnabled=1′ EstimatedInstalledBytes=”225000000″ EstimatedInstallSeconds=”420″> <InstallConditions> <BypassIf Property=”ProcessorArchitecture” Compare=”ValueNotEqualTo” Value=”amd64″/> </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 Express R2</String> <String Name=”Culture”>en</String> <String Name=”SqlExpr32Exe”>http://go.microsoft.com/fwlink/?LinkID=153228amp;clcid=0×409</String> <String Name=”SqlExpr64Exe”>http://go.microsoft.com/fwlink/?LinkID=153229amp;clcid=0×409</String> <String Name=”AdminRequired”>You do not have the permissions required to install SQL Server 2008 Express R2. Please contact your administrator.</String> <String Name=”GeneralFailure”>An error occurred attempting to install SQL Server 2008 R2.</String> <String Name=”InvalidPlatformXP”>Windows XP Service Pack 2 or later is required to install SQL Server 2008 R2.</String> <String Name=”InvalidPlatform2K3″>Windows 2003 Service Pack 2 or later is required to install SQL Server 2008 Express R2.</String> <String Name=”MissingMSXml”>SQL Server 2008 Express R2 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 Express Service Pack 1. Contact your application vendor.</String> <String Name=”InvalidPlatformOSServicePacks”>The current operating system does not meet Service Pack level requirements for SQL Server 2008 Express Service Pack 1. 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 Express Service Pack 1 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 components, SQL Server Support Files, or .NET Framework 2.0 before continuing.</String> <String Name=”InvalidPlatformArchitecture”>This version of SQL Server 2008 Express Service Pack 1 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 Express R2.</String> <String Name=”InvalidUpgradeNotExpressCore”>The instance of SQL Server 2005 Express named ‘SQLEXPRESS’ contains components that are not included in SQL Server 2008 Express R2. SQL Server 2008 R2 cannot upgrade this instance. Please use SQL Server 2008 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 Express R2. SQL Server 2008 Express R2 cannot upgrade this instance.</String> <String Name=”InvalidUpgradeWoW”>SQL Server 2008 Express R2 (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 Express Service Pack 1 (x64).</String> </Strings></Package>
8. Copy the SQL 2008 express installers you downloaded previously into folder en.

That’s it. Now if we look in our setup project prerequisite in Visual Studio 2008…

Enjoy installing the latest version of SQL 2008 Express.