Summary: How to full uninstall and reinstall of SQL without losing your databases. This can be especially helpful if your SQL Trial expires. It can also be useful if you have a corrupt database and corrupt SQL install and want to do a resinstall of SQL and repair of your database.
I love me some Microsoft documentation! One of my clients need to do a rush install of SharePoint about 195 days ago. For the backend we installed the Trial Edition of SQL Server 2005. That is all well and good until you are ready to install the real version of SQL. The test version is Enterprise edition which doesn't have a great migration path to standard. To make a very long story short, we needed to uninstall SQL and then reinstall it from the command line. And the documentation on making this happen is miserable. So, without further ado, the commands to make this happen.
VERY IMPORTANT, read the template.ini file which is located on the CD. It goes over all the switches and is the most worthwhile piece of documentation out there. That data simply isn't included in other locations.
Uninstall:
Place CD in drive, and from the command prompt change to the directory containing the setup.exe file on the CD. Type:
start /wait setup.exe /qb REMOVE=ALL INSTANCENAME=MSSQLSERVER SAVESYSDB=1
The SAVESYSDB=1 is what sets the flag to tell SQL not to blow away your database. This is very important. The default instance name of SQL will be MSSQLSERVER. If you named yours something else you'll need to adjust accordingly. Reboot your server.
Now for the resinstall. Create a file on the C: drive of the server called SQLinstall.ini. Cut and paste the following text into the file (making the appropriate edits):
; To use this .ini file, use the /settings switch on the SQL Server 2005 Setup.exe command ;line.
; For example: start /wait setup.exe /qb /settings c:\template.ini
; SECURITY NOTE: If you create a template.ini file that contains logins and passwords, store ;the file in a secured location after use.
;--------------------------------------------------------------------
; The following line is REQUIRED when using a settings file.
[Options]
USERNAME=John Doe
COMPANYNAME=Viant
;--------------------------------------------------------------------
;This should be the directory to which you are installing SQL
INSTALLSQLDIR="D:\Program Files\Microsoft SQL Server\"
;--------------------------------------------------------------------
;If desired you can use this section to define which components you are installing
ADDLOCAL=ALL
;--------------------------------------------------------------------
; INSTANCENAME is REQUIRED; for a default instance use MSSQLSERVER
INSTANCENAME=MSSQLSERVER
;--------------------------------------------------------------------
; USESYSDB specifies the root path to the data directory of the system databases during ;upgrade.
;VERY IMPORTANT: Ensure this points to the correct directory,
;MORE IMPORTANT: DO NOT ADD DATA AFTER MSSQL, LEAVE AS IS.
USESYSDB="D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\"
;--------------------------------------------------------------------
; The services for SQL Server and Analysis Server are set auto start. To use the *ACCOUNT ;settings
; make sure to specify the DOMAIN, e.g. SQLACCOUNT=DOMAINNAME\ACCOUNT
; NOTE: When installing SQL_Engine 3 accounts are REQUIRED: SQLACCOUNT, AGTACCOUNT and SQLBROWSERACCOUNT.
SQLBROWSERACCOUNT=Viant\SQLAccount
SQLBROWSERPASSWORD=I'mAGoodPassword
SQLACCOUNT=Viant\SQLAccount
SQLPASSWORD=I'mAGoodPassword
AGTACCOUNT=Viant\SQLAccount
AGTPASSWORD=I'mAGoodPassword
ASACCOUNT=Viant\SQLAccount
ASPASSWORD=I'mAGoodPassword
RSAccount=Viant\SQLAccount
RSPASSWORD=I'mAGoodPassword
;Note - this account does not exist on my domain.
;--------------------------------------------------------------------
; To use the *AUTOSTART features, specify 1 to start automatically or 0 to start manually.
SQLBROWSERAUTOSTART=1
SQLAUTOSTART=1
AGTAUTOSTART=1
ASAUTOSTART=0
RSAUTOSTART=0
;--------------------------------------------------------------------
; To use Mixed mode authentication, use SECURITYMODE=SQL.
; If SECURITYMODE=SQL is not specified, then Windows Authentication only will be used by ;default.
; If you use SQL Authentication, you are REQUIRED to provide a strong system administrator ;(SA) password.
; If you use Windows Authentication, the SA account will be disabled.
; To set SA password specify SAPWD.
SECURITYMODE=SQL
SAPWD=********
;--------------------------------------------------------------------
You are now home free. The last part is to open a command prompt, browse to the location of the setup.exe file on your CD and run:
start /wait setup.exe /qb /settings c:\SQLInstall.ini.
If you come across this and it helps you out, let me know. I realize lots of details are not fleshed out, so if you need help, let me know that too. I was not able to find this process documented anywhere which made the process far more time consuming than it needed to be. I hope by posting this I can save someone the headache that I have right now (it's 2:30 in the morning and I just finished the install).