I have changed my hard disk. My all databases are on old hard disk. I have attached my old hard disk as external hard disk. Now how can I attach database files from external hard disk to new installed SQL Server?
2 Answers
You could use SQL Server Management Studio to do this:
- In SQL Server Management Studio
Object Explorer, connect to an instance of the Microsoft SQL Server Database Engine, and then expand that instance. - Right-click
Databasesand clickAttach. - In the Attach Databases dialog box, to specify the database to be attached, click
Add; and in the Locate Database Files dialog box, select the disk drive where the database resides and expand the directory tree to find and select the.mdffile of the database;
Source: https://msdn.microsoft.com/en-us/library/ms190209(v=sql.105).aspx
Please note that you need to copy the files to the new server's file system before you can attach them. Thanks marc_s for pointing it out.
8 Comments
Ans Bilal
I tried this but object Explorer is not showing files in that directory.
Dávid Molnár
And what files are in that directory?
Ans Bilal
yes files are in that directory. It is data directory of older sql server
Dávid Molnár
I don't understand. Are there
.mdf files in that directory?Ans Bilal
It has two files of each database, database file and log file. H:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA
|
sqlcmd)