Install Sonar on Windows connected to a MSSQL-Database

To run Sonar on Windows connected to a MSSQL-Database there are a few things to be known:
In my example I installed Sonar to a 64bit Windows machine. But as for other reasons the <JAVA-HOME>-PATH-variable pointed to a 32bit Java installation I installed the 32bit Sonar.

Download sonar from http://www.sonarsource.org/downloads/ and extract it to Your program folder (<sonar>)
Open the MSSQL-Administrator and create a database called "SONAR"
Edit the file <sonar>/conf/sonar.properties
Insert the database user and its password:
sonar.jdbc.username: <user>
sonar.jdbc.password: <password>

As Sonar comes with Derby support comment or delete everything concerning Derby:
# Comment the following lines to deactivate the default embedded database.
#sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
#sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
#sonar.jdbc.validationQuery: values(1)

Uncomment and insert the data for the connection to the MSSQL-database:
#----- Microsoft SQLServer
# The Jtds open source driver is available in extensions/jdbc-driver/mssql. More details on http://jtds.sourceforge.net
# The validation query is optional.
sonar.jdbc.url: jdbc:sqlserver://<database server>;databaseName=SONAR;instanceName=<database instance>;selectMethod=cursor;
sonar.jdbc.driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
sonar.jdbc.validationQuery: select 1

Set the value of SQL-dialect to mssql further downwards in the file:
# Values are : mysql, mssql, derby, oracle, postgresql
sonar.jdbc.dialect= mssql

Save the file <sonar>/conf/sonar.properties
Go to the directory: <sonar>/extensions/jdbc-driver/mssql
Delete the existing driver: jtds-1.2.4.jar
Download and unzip the file sqljdbc_3.0.1301.101_enu.exe or sqljdbc_3.0.1301.101_enu.tar.gz from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a737000d-68d0-4531-b65d-da0f2a735707
Copy the file sqljdbc4.jar from the unzipped data into the driver directory of Sonar (<sonar>/extensions/jdbc-driver/mssql).
Now start Sonar for the first time by double clicking <sonar>/bin/windows-x86-32/StartSonar.bat
The database will be created but you will expierence some errors. So stop Sonar again.
Open the MSSQL-Administrator and change the settings of following rows from nvarchar to ntext:
SONAR.dbo.properties.text_value (ntext)
SONAR.dbo.snapshot_sources.data(ntext)
Now start Sonar again; it should run without errors.
You can install Sonar as a NT-Service by double clicking <sonar>/bin/windows-x86-32/InstallNTService.bat
If the service will not run without errors, navigate to the NTService Administration, stop Sonar and let it run with an account that owns a temp directory. (see: http://docs.codehaus.org/display/SONAR/Frequently+Asked+Questions#FrequentlyAskedQuestions-Failedtostarton64bitWindows7)


I hope I could help You!