The. mdf file is a major data file in the database. it is the starting point of the database and points to other parts of the database file. When the computer fails and the database cannot be backed up, you can only use SQL commands to attach the. mdf data file to the current server to restore the original data. Open the query analyzer and click OK to connect to the server (enter the password if SA has a password ). the mdf file is a major data file in the database. it is the starting point of the database and points to other parts of the database file. When the computer fails and the database cannot be backed up, you can only use SQL commands to attach the. mdf data file to the current server to restore the original data. Open the query analyzer and click OK to connect to the server (enter the password if SA has a password), as shown below:
Go to the query Analyzer:
In the window on the right, enter the file recovery command in the format:
Sp_attach_single_file_db @ dbname = 'dbname'
, @ Physname = 'physical _ name'
Dbname: name of the database to be restored.
Physname: physical file name.
Physical_name: specifies the. mdf file path.
For example, the IT2000.mdf file is restored to the current server.
Click the execution button shown above to restore the original IT2000 Database. the command line prompts that the command has been executed.