SQL Server: Importing database from .mdf?
Open SQL Management Studio Express and log in to the server to which you want to attach the database. In the 'Object Explorer' window, right-click on the 'Databases' folder and select 'Attach...' The 'Attach Databases' window will open; inside that window click 'Add...' and then navigate to your .MDF file and click 'OK'. Click 'OK' once more to finish attaching the database and you are done. The database should be available for use.best regards :)
See: How to: Attach a Database File to SQL Server Express
Login to the database via sqlcmd:
sqlcmd -S Server\Instance
And then issue the commands:
USE [master]GOCREATE DATABASE [database_name] ON ( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data\<database name>.mdf' ),( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data\<database name>.ldf' ) FOR ATTACH ;GO
To perform this operation see the next images:
and next step is add *.mdf file,
very important, the .mdf file must be located in C:......\MSSQL12.SQLEXPRESS\MSSQL\DATA
Now remove the log file