Database file loading and hang

xiaoxiao2021-03-06  56

Copy the database's data file (* .mdf) and log file (* .ldf) to the destination server, in SQL

Server Query Analyzer Recovery with statements:

EXEC SP_ATTACH_DB @dbname = 'Test',

@ filename1 = 'd: /msql7/data/test_data.mdf',

@ filename2 = 'd: /msql7/data/test_log.ldf'

This attaches the Test database to the SQL Server and can be used as usual. If you don't want to use the original login

Piece, you can use the following command:

EXEC SP_DETACH_DB @dbname = 'Test'

EXEC SP_ATTACH_SINGLE_FILE_DB @dbname = 'Test',

@physname = 'd: /msql7/data/test_data.mdf'

The role of this statement is to load only data files, and the log file can be added automatically by the SQL Server database, but

The data recorded in the original log file is lost.

转载请注明原文地址:https://www.9cbs.com/read-117035.html

New Post(0)