To restore a database backup with we can used the SQL command next:
CREATE DATABASE [dbname]; -- Create a database (If it was created is not necessary)
RESTORE DATABASE [dbname]
FROM DISK = ‘PATH_OF_THE_BACKUP’ -- Path of the backup file
WITH REPLACE,
MOVE ‘dbname_Data’ TO ‘DEST_PATH/dbname_Data.MDF’, -- File Path database or where we put
MOVE ‘dbname_Log’ TO ‘DEST_PATH/dbname_Log.LDF’ -- Same as above but for the log
This can be done from SQL Query Analyzer or any applications that do allow us to execute sentiencias SQL on database.
NOTE: Sorry for my english, but i am learning. I accept corrections.
(NOTE: was migrated of the old site)
On occasions it happens that the name of the database or backup do not correspond to the ID of database contained in backup, for example, our database is called SYS, but when it was created is called SYS-SA, therefore the initial names of the data and logs files were SYS_SA_Data and SYS_SA_Log.
If we try to restore we need know these names files, for this we can use the following SQL statment, that show this information and which also gives us the type, size and maximum size of the database.
RESTORE FILELISTONLY
FROM DISK = 'PATH_OF_THE_BACKUP' -- this is the backup file path
NOTE: Sorry for my english, but i am learning. I accept corrections.
(NOTE: was migrated of the old site)