Reading failed on "E:\db\Custom\201610211635.bak": 38 (The end of the file has been reached.) (Microsoft SQL Server, error: 3203)

【problem】

An exception occurred while restoring the SQL database and executing Transact-SQL statements or batches. (Microsoft.SqlServer.ConnectionInfo) Failed to read on "C:\XX.bak": 38 (The end of the file has been reached.) (Microsoft SQL Server, error: 3203).    

【analysis】

There may be a problem with the copied file, which usually exists when the local disk has bad sectors. It may be due to the format of the physical disk, or its file logic incompatibility. 

【Solution】  

1. Enter the command cmd to enter the command line, enter sqlcmd and press Enter.

 2. Enter the following sentence and press Enter  

[sql] view plain copy

  1. RESTORE DATABASE The restored database name FROM DISK ='D:\db.bak (backup file)' WITH REPLACE, MOVE'Db (former mdf logical name)' TO'D:\Db.mdf (mdf restored path )', MOVE'Db_log (formerly ldf logical name)' TO'D:\Db_log.ldf (path after ldf restoration)'  

E.g:

 

[sql] view plain copy

  1. RESTORE DATABASE xzcrm FROM DISK = 'E:\db\201610211600.bak' WITH REPLACE   
  2. , MOVE 'xzcrm_Data' TO 'E:\db\Custom\xzcrm.mdf'  
  3. , MOVE 'xzcrm_Log' TO 'E:\db\Custom\xzcrm_log.ldf'   

3. Then enter go and press Enter to execute.

Guess you like

Origin blog.csdn.net/szlixiaolong/article/details/109216305