Note: For my updated version for SQL Server 2012, see my new article here.
Many of you probably do frequent SQL 2008 R2 installation. Be it in a development environment, or deployment in production environments. For years Microsoft has given people the ability to perform unattended installations of SQL. Starting with SQL 2008 R2, it is now sysprep friendly and can be included in your golden images. But that topic is for another time! Today I wanted to provide you two scripts that automate the SQL 2008 R2 installation process the old fashion way.
You can deploy SQL 2008 R2 in 5-7 minutes, depending on your hardware using this method. You will of course need to modify some variables in the script to fit your environment. The scripts assume you are deploying on Windows Server 2008 R2. They should work with minor to no modifications on legacy operating systems.
First, you need to create an INI file that contains the settings you want. In my case I called it SQL-2008R2-base.ini. That file contains the following:
;SQL SERVER 2008 R2 Configuration File
;Version 1.0, 5 May 2010
; Specify the Instance ID for the SQL Server features you have specified. SQL Server directory structure, registry structure, and service names will reflect the instance ID of the SQL Server instance.
; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. This is a required parameter.
; Specifies features to install, uninstall, or upgrade. The list of top-level features include SQL, AS, RS, IS, and Tools. The SQL feature will install the database engine, replication, and full-text. The Tools feature will install Management Tools, Books online, Business Intelligence Development Studio, and other shared components.
; Displays the command line parameters usage
; Specifies that the detailed Setup log should be piped to the console.
; Setup will not display any user interface.
; Setup will display progress only without any user interaction.
; Specifies that Setup should install into WOW64. This command line argument is not supported on an IA64 or a 32-bit system.
; Specifies the path to the installation media folder where setup.exe is located.
; Detailed help for command line argument ENU has not been defined yet.
; Parameter that controls the user interface behavior. Valid values are Normal for the full UI, and AutoAdvance for a simplied UI.
; Specify if errors can be reported to Microsoft to improve future SQL Server releases. Specify 1 or True to enable and 0 or False to disable this feature.
; Specify the root installation directory for native shared components.
INSTALLSHAREDDIR=”D:Program FilesMicrosoft SQL Server”
; Specify the root installation directory for the WOW64 shared components.
INSTALLSHAREDWOWDIR=”D:Program Files (x86)Microsoft SQL Server”
; Specify the installation directory.
INSTANCEDIR=”D:Program FilesMicrosoft SQL Server”
; Specify that SQL Server feature usage data can be collected and sent to Microsoft. Specify 1 or True to enable and 0 or False to disable this feature.
; Specify a default or named instance. MSSQLSERVER is the default instance for non-Express editions and SQLExpress for Express editions. This parameter is required when installing the SQL Server Database Engine (SQL), Analysis Services (AS), or Reporting Services (RS).
; Agent account name
AGTSVCACCOUNT=”NT AUTHORITYNETWORK SERVICE”
; Auto-start service after installation.
; Startup type for Integration Services.
; Account for Integration Services: DomainUser or system account.
; Controls the service startup type setting after the service has been created.
; The collation to be used by Analysis Services.
; The location for the Analysis Services data files.
; The location for the Analysis Services log files.
; The location for the Analysis Services backup files.
; The location for the Analysis Services temporary files.
; The location for the Analysis Services configuration files.
; Specifies whether or not the MSOLAP provider is allowed to run in process.
; A port number used to connect to the SharePoint Central Administration web application.
; Startup type for the SQL Server service.
; Level to enable FILESTREAM feature at (0, 1, 2 or 3).
; Set to “1” to enable RANU for SQL Server Express.
; Specifies a Windows collation or an SQL collation to use for the Database Engine.
; Account for SQL Server service: DomainUser or system account.
SQLSVCACCOUNT=”NT AUTHORITYNETWORK SERVICE”
; Default directory for the Database Engine user databases.
SQLUSERDBDIR=”K:Microsoft SQL ServerMSSQLData”
; Default directory for the Database Engine user database logs.
SQLUSERDBLOGDIR=”L:Microsoft SQL ServerMSSQLDataLogs”
; Directory for Database Engine TempDB files.
SQLTEMPDBDIR=”T:Microsoft SQL ServerMSSQLData”
; Directory for the Database Engine TempDB log files.
SQLTEMPDBLOGDIR=”T:Microsoft SQL ServerMSSQLDataLogs”
; Provision current user as a Database Engine system administrator for SQL Server 2008 R2 Express.
; Specify 0 to disable or 1 to enable the TCP/IP protocol.
; Specify 0 to disable or 1 to enable the Named Pipes protocol.
; Startup type for Browser Service.
; Specifies how the startup mode of the report server NT service. When
; Manual – Service startup is manual mode (default).
; Automatic – Service startup is automatic mode.
; Disabled – Service is disabled
; Specifies which mode report server is installed in.
; Default value: “FilesOnly”
; Accept SQL Server 2008 R2 license terms
Next, you need to use a little script which calls the SQL installer and points it to the INI file that you’ve created. This script needs one parameter, the name of the SQL administrator’s group. Generally this group would live in AD. You should use the format domainaccount as the parameter. The script also configures Windows Server 2008 R2 auditing so that SQL can inject entries into the Windows security event log. The SQL 2008 R2 installation files must be present on the Z: drive, or you will need to change the script. I save this file as SQL-2008R2-Base.cmd.
:: SQL 2008 R2 Installation Script:: v1.1 03 July 2010
IF “%1″==”” GOTO Error
:: Install base SQL Server 2008 Enterprise
echo Installing base SQL Server 2008 R2…
“z:setup.exe” /CONFIGURATIONFILE=D:sql-2008R2-Base.ini /INDICATEPROGRESS /SQLSYSADMINACCOUNTS=”%1″
:: Configure Windows Server 2008/R2 auditing policy
auditpol /set /subcategory:”application generated” /success:enable /failure:enable
:: Remove left-over SQL 2008 entry from the start menu
rmdir “C:ProgramDataMicrosoftWindowsStart MenuProgramsMicrosoft SQL Server 2008″ /q /s
:ErrorEcho Script requires DBAdmin argument in the form domainGroup
To peform the unattended installation I perform the following steps:
1. Mount SQL 2008 R2 installation files to the Z drive.
2. Copy the two scripts to the root of the D: drive.
3. Open a command window and CD to the Z: drive.
4. Type “D:SQL-2008R2-base.cmd contosoSQL01-DBAdmin” (use your group name)
Come back in 5-10 minutes and you should get a setup result of “0”. Happy SQL installs! If you want to get really crazy with the switches, check out this MSDN Aritcle for all the options.