Friday, September 14, 2012

How to Create Sample Database in MSSQL with Sample Data

This is very useful for application testing.

First you have to download the relevant sample databases from http://msftdbprodsamples.codeplex.com/releases/view/59211

Then copy the relevant AdventureWorks2008R2_Data.mdf file in to your machine where the MSSQL is installed. then go to MSSQL Editor and run the following query

[sourcecode language="sql"]

CREATE DATABASE AdventureWorks2012
ON (FILENAME = 'D:\AdventureWorks2012_Data.mdf')
FOR ATTACH_REBUILD_LOG ;

[/sourcecode]

Don't delete the above AdventureWorks2008R2_Data.mdf because this will be your database in MSSQL

No comments:

Post a Comment