Friday, February 17, 2012

Database creation

I downloaded the sample database AdventureWorks from microsoft . When I run the download it created the data and log files under data folder in MSQLalong with other data and log files of master databases etc. However I do not see this database in SQLserver management studio. Can some one help me how to fix this so that I will be able to see this database in management studio.

I am downloading this for SQL server reporting purpose

Hi Kash,

The sample database installation delivers the database files to your machine, but does not "attach" the database to a specific SQL instance.

To attach the database you could do one of the following:

(1) Execute the following query:

USE master
GO
EXEC sp_attach_db 'AdventureWorksDW', '<path to your MDF file>AdventureWorksDW_Data.mdf', '<path to your LDF file>AdventureWorksDW_Log.ldf'

(you could use whatever name you like and also - make sure the MDF and LDF file names are correct, too)

(2) In SQL Management Studio, right-click the Databases folder, select "Attach". Navigate to the folder where the MDF file is installed and select it.

With either steps, the database is attached, recovered and comes online. BTW - this is a good way to move or rename a database: detach, move, attach (possibly under different name).

HTH,

Jivko Dobrev - MSFT
--
This posting is provided "AS IS" with no warranties, and confers no rights.

No comments:

Post a Comment