Translate

Tuesday, 20 June 2017

sql: restore sql database using sql query

--Step: 1
---------
--Get the FILELISTONLY of backup file in disk location
    RESTORE FILELISTONLY
    FROM DISK ='E:\Pabitra\dbSample.BAK'
    -- Find the "LogicalName" column MDFLogicalName and LDFLogicalName which is use inthe next query
    --My MDFLogicalName is dbSample and LDFLogicalName is dbSample_log
    -- then Run the below code
--Step : 2
---------
RESTORE DATABASE dbNewName
FROM DISK ='E:\Pabitra\dbSample.BAK'
WITH MOVE 'dbSample' TO 'E:\Pabitra\dbNewName.mdf',
MOVE 'dbSample_log' TO 'E:\Pabitra\dbNewName.ldf'

No comments:

Post a Comment