How to restore the SQL SERVER database through Query ?
Question :
Hi,
Everybody knows that restoring the database from backup file through sql server restore wizard. but sometimes we may get error while restoring through sql server restore wizard like 'failed,Reached the end of the file'.
Now you can get success restore by restoring through query.
Answer :
Restore the database through query by following,
1. JUST TO GET HEADER DETAILS
RESTORE HEADERONLY
FROM DISK = N'D:\DB\SPICE.bak'
WITH NOUNLOAD;
GO
2. TO KNOW THAT BACKUP FILE IS CORRUPTED
RESTORE VERIFYONLY
FROM DISK = N'D:\DB\SPICE.bak'
GO
3. EXECUTE THIS AND YOU WILL GET LOGICAL NAME FOR TYPE D AND L (i,e DATA FILE AND LOGICAL FILE )
RESTORE FILELISTONLY
FROM DISK = N'D:\DB\SPICE.bak'
4. TO RESTORE BAK FILE IN NEW DATABASE
RESTORE DATABASE NEWDB
FROM DISK = N'D:\DB\SPICE.bak'
WITH REPLACE ,
MOVE 'MDF_FILENAME'
-- SPECIFY LOGICAL NAME OF DATAFILE HERE FROM THE ABOVE FETCH (ie where type = D)
TO 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Spice.mdf', -- SPECIFY NEW DATAFILE NAME
MOVE 'LDF_FILENAME'
-- SPECIFY LOGICAL NAME OF LOGICALFILE FROM THE ABOVE FETCH (ie where type = L)
TO 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Spice_log.ldf' -- SPECIFY NEW LOGICALFILE NAME
5. Now you will get success restore message.
Question :
Hi,
Everybody knows that restoring the database from backup file through sql server restore wizard. but sometimes we may get error while restoring through sql server restore wizard like 'failed,Reached the end of the file'.
Now you can get success restore by restoring through query.
Answer :
Restore the database through query by following,
1. JUST TO GET HEADER DETAILS
RESTORE HEADERONLY
FROM DISK = N'D:\DB\SPICE.bak'
WITH NOUNLOAD;
GO
2. TO KNOW THAT BACKUP FILE IS CORRUPTED
RESTORE VERIFYONLY
FROM DISK = N'D:\DB\SPICE.bak'
GO
3. EXECUTE THIS AND YOU WILL GET LOGICAL NAME FOR TYPE D AND L (i,e DATA FILE AND LOGICAL FILE )
RESTORE FILELISTONLY
FROM DISK = N'D:\DB\SPICE.bak'
4. TO RESTORE BAK FILE IN NEW DATABASE
RESTORE DATABASE NEWDB
FROM DISK = N'D:\DB\SPICE.bak'
WITH REPLACE ,
MOVE 'MDF_FILENAME'
-- SPECIFY LOGICAL NAME OF DATAFILE HERE FROM THE ABOVE FETCH (ie where type = D)
TO 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Spice.mdf', -- SPECIFY NEW DATAFILE NAME
MOVE 'LDF_FILENAME'
-- SPECIFY LOGICAL NAME OF LOGICALFILE FROM THE ABOVE FETCH (ie where type = L)
TO 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Spice_log.ldf' -- SPECIFY NEW LOGICALFILE NAME
5. Now you will get success restore message.
No comments:
Post a Comment