Silverlight basics [1]: Recovering from MDF files to SQL Server databases

Source: Internet
Author: User
Tags microsoft sql server management studio

Notes: [1] Recovering from MDF file to SQL Server database

In the project, if you want to recover data from the MDF database to the SQL Server database, perform the following operations:
1. log on to mssms (Microsoft SQL Server Management studio) to create a database with the same name.
2. Open the directory of the new database and delete its log file test_data.ldf.
3. Open mssms, right-click the database you created, select "task", and select "offline ".
4. Create a query and execute the following statement:

 
Exec sp_detach_db @ dbname = 'database' exec sp_attach_single_file_db @ dbname = 'database', @ physname = 'e: \ webdemo \ database. MDF'

5. Set the new database to online and refresh the database.

 there are three types of files in the Microsoft SQL Server database: 1. Main data files (extension. MDF is the abbreviation of primary data file) the main data file contains the database startup information and points to other files in the database. User Data and objects can be stored in this file, or in secondary data files. Each database has a primary data file. The recommended file extension for main data files is. MDF. Each database of SQL Server is stored in two files. One suffix is MDF, which is a data file and the other suffix is LDF, which is a log file. Therefore, you only need to copy these two files regularly to achieve the backup effect. 2. secondary data files (extension. NDF is short for secondary data files) are optional and user-defined and stored. By placing each file on a different disk drive, secondary files can be used to distribute data to multiple disks. In addition, if the database exceeds the maximum size of a Single Windows file, you can use secondary data files so that the database can continue to grow. The recommended file extension for secondary data files is. NDF. 3. Transaction Log (the extension. LDF is the abbreviation of log data files) stores the log information used to restore the database. Each database must have at least one log file. The recommended file extension for transaction logs is. LDF. 
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.