Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / database / SQL-Server / SQL-Server-2008

Inno Setup Script to Install SQL Server 2008 R2 with Tools

5.00/5 (2 votes)
1 Dec 2013Public Domain 35.1K  
Inno Setup script to install SQL Server 2008 R2 with Tools, creating an instance with special rights and displaying the log.

Introduction

If you want to distribute your program with SQL Server, it's nice for the end user to have an installer that silently does the hard work like choosing the right options and set an instance name.

Prerequisites

You need the Inno Setup installer which can be found on SourceForge:

SQL Server 2008 R2 with Tools can be downloaded from

Background

For my purposes, I needed to install a Windows Service that could connect to SQL Server, which is not possible with a default installation of SQL Server 2008 or higher.

The following option sets the right authorization level:

/SQLSVCACCOUNT="NT AUTHORITY\SYSTEM"  

Using the Code

The example code is for 64 bits installation only.

Compile the following Inno Setup script to create the setup.exe:

;
; Inno Setup script to install SQL Server 2008 R2 with Tools.
; (see download link below for details)
; Shows the install log summary after install.
; 
; Creates instance MYINSTANCE
; Log in from SMSS with: <Computername>\MYINSTANCE
;
#define MyAppName "SQL Server 2008 R2 with Tools"
#define MyAppVersion "1"
#define MyAppPublisher "Test"
#define MyAppURL "http://www.microsoft.com/en-us/download/details.aspx?id=23650"

[Setup]
AppId={{84CDA882-8CF1-4487-85AB-DF7BA0741D2A}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
CreateAppDir=no
OutputBaseFilename=setup
Compression=none
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "SQLEXPRWT_x64_ENU.exe"; DestDir: "{tmp}"; Flags: ignoreversion

[RUN]
Filename: "{tmp}\SQLEXPRWT_x64_ENU.exe"; 
Parameters: "/Q /IACCEPTSQLSERVERLICENSETERMS /ACTION=Install /FEATURES=SQL,
Tools /INSTANCENAME=MYINSTANCE /SQLSVCACCOUNT=""
NT AUTHORITY\SYSTEM"" /SQLSYSADMINACCOUNTS=""BUILTIN\ADMINISTRATORS"" 
/AGTSVCACCOUNT=""NT AUTHORITY\Network Service"" "; Check: IsWin64()
Filename: "Notepad.exe"; 
Parameters: "{pf}\Microsoft SQL Server\100\Setup Bootstrap\Log\Summary.txt";

Points of Interest

Of course, you could also use a batch file to install SQL Server this way.

Be aware that most versions of SQL Server have slightly different command line options if you are planning to use another version than SQL Server 2008 R2 !

History

  • Version 1

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication