This article is written very well, very useful ~ Thank You blog share
In peacetime development, often encounter database SQL Server such as import mdf,ldf file problem, below to introduce you how to do, hope to help you.
Tools/Materials
Method/Step One: Code method
- 1
Open SQL Server and you can choose a Windows-mode connection.
- 2
Open the database, right-click a database, and select New Query (Q).
- 3
Re-code interface to enter the following code, click the F5 key or click the Run button.
The code is as follows:
EXEC sp_attach_db @dbname = ' Your database name ',
@filename1 = ' MDF file path (package prefix name) ',
@filename2 = ' LDF file path (package prefix name) '
- 4
You can see that the import was successful. If the import is unsuccessful, you need to modify the permissions of the Mdf,ldf file. Right-click Properties-Security-Edit, Full Control select Allow.
- 5
This can solve the problem of import, of course, sometimes encounter version incompatibility issues, the lower version cannot import the high version of the SQL MDF and LDF files.
END
Method/step: Attach Mdf,ldf file directly
At the database, right-click Attach to open the additional interface.
In the "Attach Database" interface, add MDF files and click "OK".
If the import has an error, you can do so with the first method.
END
Precautions
How SQL Server imports Mdf,ldf files (reproduced)