Reinstalling Sample Databases from Script

SQL Server Setup

If you have made changes to a sample database and want to return to the original schema, you can reinstall the database by running the appropriate installation script from Microsoft SQL Server Management Studio Query Editor. The installation script removes the existing sample database, re-creates the database objects, and populates the tables.

Alternatively, you can download the AdventureWorks database at the SQL Server Developer Web site.

Note:
These procedures do not apply to SQL Server 2005 Express Edition or SQL Server 2005 Compact Edition. To download AdventureWorks for these editions, see Installing Sample Databases for Express Editions.

The following procedures describe how to reinstall the AdventureWorks database and the AdventureWorksDW data warehouse.

To reinstall AdventureWorks from script

  1. On the Management Studio toolbar, click File, point to Open and then click File.

  2. Browse to the file instawdb.sql and click Open. The default location of this file is C:\Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks OLTP.

  3. Before running the script, locate the statement SET @data_path = @sql_path + 'AWDB\'; in the script and change the statement to point to the location of the instawdb.sql script. For example, SET @data_path = 'C:\Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks OLTP\';.

  4. Execute the script.

To reinstall AdventureWorksDW from script

  1. On the Management Studio tool bar, click File, point to Open and then click File.

  2. Browse to the file instawdwdb.sql and click Open. The default location of this file is C:\Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks Data Warehouse.

  3. Before running the script, locate the statement SET @data_path = @sql_path + 'awdwdb\'; in the script and change the statement to point to the location of the instawdwdb.sql script. For example, SET @data_path = 'C:\Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks Data Warehouse\';.

  4. Execute the script.

See Also