The other day I needed to attach the Adventure 2008 sample databases to my test server. So I downloaded the self extractor from codeplex and hit run… and got this error:
So, of course I hit Google and got several suggestions along the lines of:
- Ensure the database version matches the SQL Server version.
- Have only one SQL Instance running.
- Put the installer in the correct path.
- There is an issue with filestream – download the without filestream option.
All good suggestions but I am working on a test box, I have about half a dozen SQL instances (usually all stopped) with different versions and configurations. I want to be able to install Adventure Works 2008 (because that’s what’s used in a book I’m working through) on to my2008R2 instance (because I want to okay). And finally I want fairly granular control over where I put stuff.
Here’s what I did:
1. Rename the extractor file – change .exe to .zip.
2. Extract the file (double click should do it).
3. In the extracted folder there are sub-folders for the various Adventure Works databases:
4. Each of these subfolders contains a script file (instawdb.sql) and a bunch of csv files. Load the install script for the database you want into SSMS.
5. The script must be run in SQLCMD mode. (Query > SQLCMD Mode)
6. Near the top of this script file are two lines:
--:setvar SqlSamplesDatabasePath "C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\" --:setvar SqlSamplesSourceDataPath "C:\Program Files\Microsoft SQL Server\100\Tools\Samples\"
7. Uncomment these. The first line should point to where the database files will be created. Mdf and ldf files will both be created in this directory but this can be altered later
8. The second line should point to the location of the subfolder containing the csv files.
9. Run the script – this will create and populate the database of your choice.
10. Rinse and repeat.