How SQL Server imports Mdf,ldf files (reproduced)

Source: Internet
Author: User

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
    • SQL Server

    • Mdf,ldf file

Method/Step One: Code method
    1. 1

      Open SQL Server and you can choose a Windows-mode connection.

    2. 2

      Open the database, right-click a database, and select New Query (Q).

    3. 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. 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. 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
    1. At the database, right-click Attach to open the additional interface.

    2. In the "Attach Database" interface, add MDF files and click "OK".

    3. If the import has an error, you can do so with the first method.

      END
Precautions
    • The second method goes wrong, using the first.

    • The database is to be installed correctly.

How SQL Server imports Mdf,ldf files (reproduced)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.