I have been sent a database called StudentsDB.mdf and I want to enter it into my SQL Server Management Studio databases . How to do that ?
I want to know if I copy a .mdf file from the directory where are all my databases which is C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA and sent it to another person will he be able to import this database in his SQL Server Management Studio and see the database?
Try this one
Step 1 Right-click “Databases” and click the “Attach” option to open the Attach Databases dialog box.
Step 2 Click the “Add” button to open the Locate Database Files dialog box.
Step 3 Type in the full name of the .MDF file, including the full device and directory path, as the following example illustrates: c:\StudentsDB.mdf Click the "OK" button. SQL Server Management Studio loads the database from the .MDF file.
OR
Step 1 Click “New Query” in the Management Studio’s main toolbar.
Step 2 Type a Create Database statement using the following Transact-SQL code:
CREATE DATABASE MyDatabase ON
(FILENAME = 'c:\StudentsDB.mdf'),
(FILENAME = ' c:\StudentsDB.ldf') FOR ATTACH;
Step 3 Click the “Execute” button in the Transact-SQL toolbar. SQL Server Management Studio restores the database.
OR
CREATE DATABASE StudentDB ON
(FILENAME = N'C:\StudentsDB.mdf')
FOR ATTACH_REBUILD_LOG
GO