How to copy SQL Server 2008 R2 database from one machine to another
I have a database in SQL Server 2008 R2, and I want to copy this database onto another machine.
How do I make a copy?
And how do I restore it?
Thanks
sql sql-server-2008-r2
add a comment |
I have a database in SQL Server 2008 R2, and I want to copy this database onto another machine.
How do I make a copy?
And how do I restore it?
Thanks
sql sql-server-2008-r2
2
Have you tried a few searches, surely there is already resource out there for this?
– JsonStatham
Sep 18 '13 at 7:42
2
just take a backup of the database and restore it to the other machine - technet.microsoft.com/en-us/library/ms186390.aspx
– NDJ
Sep 18 '13 at 7:44
I have already made a search but didn't get proper answer
– DK007
Sep 18 '13 at 7:48
please tell me step that how to make backup and restore
– DK007
Sep 18 '13 at 7:52
easiest way select the database in the source server in SSMS Right click ->Tasks->Copy Database Wizard to launch the copy database wizard.
– Justin
Sep 18 '13 at 8:04
add a comment |
I have a database in SQL Server 2008 R2, and I want to copy this database onto another machine.
How do I make a copy?
And how do I restore it?
Thanks
sql sql-server-2008-r2
I have a database in SQL Server 2008 R2, and I want to copy this database onto another machine.
How do I make a copy?
And how do I restore it?
Thanks
sql sql-server-2008-r2
sql sql-server-2008-r2
edited Sep 18 '13 at 8:21
marc_s
572k12811041252
572k12811041252
asked Sep 18 '13 at 7:34
DK007DK007
1071515
1071515
2
Have you tried a few searches, surely there is already resource out there for this?
– JsonStatham
Sep 18 '13 at 7:42
2
just take a backup of the database and restore it to the other machine - technet.microsoft.com/en-us/library/ms186390.aspx
– NDJ
Sep 18 '13 at 7:44
I have already made a search but didn't get proper answer
– DK007
Sep 18 '13 at 7:48
please tell me step that how to make backup and restore
– DK007
Sep 18 '13 at 7:52
easiest way select the database in the source server in SSMS Right click ->Tasks->Copy Database Wizard to launch the copy database wizard.
– Justin
Sep 18 '13 at 8:04
add a comment |
2
Have you tried a few searches, surely there is already resource out there for this?
– JsonStatham
Sep 18 '13 at 7:42
2
just take a backup of the database and restore it to the other machine - technet.microsoft.com/en-us/library/ms186390.aspx
– NDJ
Sep 18 '13 at 7:44
I have already made a search but didn't get proper answer
– DK007
Sep 18 '13 at 7:48
please tell me step that how to make backup and restore
– DK007
Sep 18 '13 at 7:52
easiest way select the database in the source server in SSMS Right click ->Tasks->Copy Database Wizard to launch the copy database wizard.
– Justin
Sep 18 '13 at 8:04
2
2
Have you tried a few searches, surely there is already resource out there for this?
– JsonStatham
Sep 18 '13 at 7:42
Have you tried a few searches, surely there is already resource out there for this?
– JsonStatham
Sep 18 '13 at 7:42
2
2
just take a backup of the database and restore it to the other machine - technet.microsoft.com/en-us/library/ms186390.aspx
– NDJ
Sep 18 '13 at 7:44
just take a backup of the database and restore it to the other machine - technet.microsoft.com/en-us/library/ms186390.aspx
– NDJ
Sep 18 '13 at 7:44
I have already made a search but didn't get proper answer
– DK007
Sep 18 '13 at 7:48
I have already made a search but didn't get proper answer
– DK007
Sep 18 '13 at 7:48
please tell me step that how to make backup and restore
– DK007
Sep 18 '13 at 7:52
please tell me step that how to make backup and restore
– DK007
Sep 18 '13 at 7:52
easiest way select the database in the source server in SSMS Right click ->Tasks->Copy Database Wizard to launch the copy database wizard.
– Justin
Sep 18 '13 at 8:04
easiest way select the database in the source server in SSMS Right click ->Tasks->Copy Database Wizard to launch the copy database wizard.
– Justin
Sep 18 '13 at 8:04
add a comment |
6 Answers
6
active
oldest
votes
There are probably more ways to do this but I usually right-click the database and choose "Tasks → Back up..." with Backup type "Full". After that you can copy the created file to your target machine, connect to its SQL Server in SQL Server Management Studio, right-click the "Databases" folder and choose "Restore Database". Select "Device" and choose the file, then restore.
Another approach would be to script the database in SQL Server Management Studio (right-click the database, then "Tasks → Generate scripts..."). During this process there'll be a step called "Set Scripting Options", where you'll have to click the "Advanced" button and carefully go through the options. You'll definitely want to choose "Data and schema" for the option "Types of data to script". I sometimes prefer this method if I really just want the data structures and the data itself to be transferred.
Update: Sorry, I forgot to mention how to restore the database for the scripting option. I always generate the scripts by selecting "Save to new query window" during the "Set Scripting Options" step. After the script is generated, just leave it there for a moment.
On the target server create a new database with the same name as the one you generated the scripts for. Or you can create a script for that on the source server, too (right-click the database, choose "Script Database as → CREATE TO... → Clipboard") and execute this script by right-clicking the server node in the SSMS Object Explorer, selecting "New query", pasting the script into the query window and executing it. This second option is the better choice if you really need a complete copy of the database and not just the data itself.
Once you've gone down one of these two roads you should have created a new database. Right-click this database in Object Explorer and select "New Query", then copy and paste the script containing the database structure and data into the new query window and execute the query. This should do the trick.
how to restore generated script into another machine
– DK007
Sep 18 '13 at 8:31
@DK007 I updated my answer.
– Onkel Toob
Sep 18 '13 at 8:47
add a comment |
You can't copy Database to another machine.
Yes you can take back up to same machine and copy it to another machine and do restore.
To take backup follow procedure:
- Right Click on the database you want to take backup.
- Choose Task -> Back Up.
- In Destination, Choose Add.
- In File Name click on
...
button and choose destination folder where you want to backup with backupname.bak . Click Ok, Ok and Ok. and wait until backup process is completed. Click Ok.
Now copy that backup file into pendrive or any media and paste it to another machine and Open SQL Server 2008 R2
To restore backup follow procedure:
- Right Click on the Databases.
- Choose Restore Database.
- Write database name which you want to restore in To Database field
- Select From device radio button in Source for restore. Click on
...
- Click on Add button, Select database backup file you have pasted. Click Ok, Ok.
- Check the checkbox of Restore in Select the beckup sets to restore.
- Go on Options Check Overwrite the existing database & Preserve the replication settings (this fields needed to check only when you try to restore database which is already resided on that another device)
- Click Ok. wait until restore complete and click ok.
Tell me if you face any problem.
By Code
To Backup:
USE DATABASE_NAME;
GO
BACKUP DATABASE DATABASE_NAME
TO DISK = 'D:DATABASE_NAME.Bak'
WITH FORMAT, MEDIANAME = 'D_SQLServerBackups',
NAME = 'Full Backup of DATABASE_NAME';
GO
(If you want to put backup in any folder, the folder must be exist before you take the backup.)
To Restore:
Step 1: Retrive the Logical file name of the database from backup.
RESTORE FILELISTONLY
FROM DISK = 'D:BackUpYourBaackUpFile.bak'
GO
Step 2: Use the values in the LogicalName Column in following Step.
----Make Database to single user Mode
ALTER DATABASE YourDB
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE
----Restore Database
RESTORE DATABASE YourDB
FROM DISK = 'D:BackUpYourBaackUpFile.bak'
WITH MOVE 'YourMDFLogicalName' TO 'D:DataYourMDFFile.mdf',
MOVE 'YourLDFLogicalName' TO 'D:DataYourLDFFile.ldf'
/If there is no error in statement before database will be in multiuser
mode.
If error occurs please execute following command it will convert
database in multi user./
ALTER DATABASE YourDB SET MULTI_USER
GO
1
+1, one remark: If the database is not present yet on the target machine, you can't right-click it in step 1 of the restore block. You can right-click the "Databases" folder, though and go from there.
– Onkel Toob
Sep 18 '13 at 8:10
add a comment |
Copying a database using a full database backup will not copy the transactions in the online transaction log.
If this is important, use the following steps to take the database offline, copy the MDF and LDF files, and attach them:
- Select the database in SQL Server Management Studio , right-click the database and select Properties. Copy the location of the MDF and LDF files
2.Click OK
3.Right-click the database again, select Tasks, Take offline
4.In Windows Explorer, copy the MDF and LDF files using the location found in step #1
5.Paste them to another location
6.In SQL Server Management Studio right-click the SQL Server instance and select Attach
7.In the next dialog, click Add, find the copied files, select them and click OK
8.Change the default name offered in the Attach AS field. Specify the new name you want for your database here.
9.Click OK
To bring back online the original database, right-click it and select Tasks, Bring online
add a comment |
if you are copying it to a SQL 2008 R2 then all u have to do is
- open SQL server management studio
- choose your database
- right click, go to Tasks --> BackUp
- in the database backup window, click add and then give your backup path and file name
click ok
copy the backup file to any drive in the machine to which you want to restore then,
- Open SQL server management studio
- create a new database
- right click on the newly created database, go to Tasks --> Restore --> Database
- on the restore window select from device option
- add the backup file path
- click ok
add a comment |
Justin's answer above was almost correct, it is simply right click on database in SSMS and select "Tasks" > "Export Data". This wizard allows you to duplicate the entire database to another location.
add a comment |
In addition for copy or move database to another server in same network level you can use SQL Server Copy Database Wizard
for use this method you should
- Right click on database
- Select task and
- Select copy database
- Fill source database server login data
- Fill destination database server login data
- Select transfer method
- Select databases to transfer(except system databases)
Extra description about this method
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f18866321%2fhow-to-copy-sql-server-2008-r2-database-from-one-machine-to-another%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are probably more ways to do this but I usually right-click the database and choose "Tasks → Back up..." with Backup type "Full". After that you can copy the created file to your target machine, connect to its SQL Server in SQL Server Management Studio, right-click the "Databases" folder and choose "Restore Database". Select "Device" and choose the file, then restore.
Another approach would be to script the database in SQL Server Management Studio (right-click the database, then "Tasks → Generate scripts..."). During this process there'll be a step called "Set Scripting Options", where you'll have to click the "Advanced" button and carefully go through the options. You'll definitely want to choose "Data and schema" for the option "Types of data to script". I sometimes prefer this method if I really just want the data structures and the data itself to be transferred.
Update: Sorry, I forgot to mention how to restore the database for the scripting option. I always generate the scripts by selecting "Save to new query window" during the "Set Scripting Options" step. After the script is generated, just leave it there for a moment.
On the target server create a new database with the same name as the one you generated the scripts for. Or you can create a script for that on the source server, too (right-click the database, choose "Script Database as → CREATE TO... → Clipboard") and execute this script by right-clicking the server node in the SSMS Object Explorer, selecting "New query", pasting the script into the query window and executing it. This second option is the better choice if you really need a complete copy of the database and not just the data itself.
Once you've gone down one of these two roads you should have created a new database. Right-click this database in Object Explorer and select "New Query", then copy and paste the script containing the database structure and data into the new query window and execute the query. This should do the trick.
how to restore generated script into another machine
– DK007
Sep 18 '13 at 8:31
@DK007 I updated my answer.
– Onkel Toob
Sep 18 '13 at 8:47
add a comment |
There are probably more ways to do this but I usually right-click the database and choose "Tasks → Back up..." with Backup type "Full". After that you can copy the created file to your target machine, connect to its SQL Server in SQL Server Management Studio, right-click the "Databases" folder and choose "Restore Database". Select "Device" and choose the file, then restore.
Another approach would be to script the database in SQL Server Management Studio (right-click the database, then "Tasks → Generate scripts..."). During this process there'll be a step called "Set Scripting Options", where you'll have to click the "Advanced" button and carefully go through the options. You'll definitely want to choose "Data and schema" for the option "Types of data to script". I sometimes prefer this method if I really just want the data structures and the data itself to be transferred.
Update: Sorry, I forgot to mention how to restore the database for the scripting option. I always generate the scripts by selecting "Save to new query window" during the "Set Scripting Options" step. After the script is generated, just leave it there for a moment.
On the target server create a new database with the same name as the one you generated the scripts for. Or you can create a script for that on the source server, too (right-click the database, choose "Script Database as → CREATE TO... → Clipboard") and execute this script by right-clicking the server node in the SSMS Object Explorer, selecting "New query", pasting the script into the query window and executing it. This second option is the better choice if you really need a complete copy of the database and not just the data itself.
Once you've gone down one of these two roads you should have created a new database. Right-click this database in Object Explorer and select "New Query", then copy and paste the script containing the database structure and data into the new query window and execute the query. This should do the trick.
how to restore generated script into another machine
– DK007
Sep 18 '13 at 8:31
@DK007 I updated my answer.
– Onkel Toob
Sep 18 '13 at 8:47
add a comment |
There are probably more ways to do this but I usually right-click the database and choose "Tasks → Back up..." with Backup type "Full". After that you can copy the created file to your target machine, connect to its SQL Server in SQL Server Management Studio, right-click the "Databases" folder and choose "Restore Database". Select "Device" and choose the file, then restore.
Another approach would be to script the database in SQL Server Management Studio (right-click the database, then "Tasks → Generate scripts..."). During this process there'll be a step called "Set Scripting Options", where you'll have to click the "Advanced" button and carefully go through the options. You'll definitely want to choose "Data and schema" for the option "Types of data to script". I sometimes prefer this method if I really just want the data structures and the data itself to be transferred.
Update: Sorry, I forgot to mention how to restore the database for the scripting option. I always generate the scripts by selecting "Save to new query window" during the "Set Scripting Options" step. After the script is generated, just leave it there for a moment.
On the target server create a new database with the same name as the one you generated the scripts for. Or you can create a script for that on the source server, too (right-click the database, choose "Script Database as → CREATE TO... → Clipboard") and execute this script by right-clicking the server node in the SSMS Object Explorer, selecting "New query", pasting the script into the query window and executing it. This second option is the better choice if you really need a complete copy of the database and not just the data itself.
Once you've gone down one of these two roads you should have created a new database. Right-click this database in Object Explorer and select "New Query", then copy and paste the script containing the database structure and data into the new query window and execute the query. This should do the trick.
There are probably more ways to do this but I usually right-click the database and choose "Tasks → Back up..." with Backup type "Full". After that you can copy the created file to your target machine, connect to its SQL Server in SQL Server Management Studio, right-click the "Databases" folder and choose "Restore Database". Select "Device" and choose the file, then restore.
Another approach would be to script the database in SQL Server Management Studio (right-click the database, then "Tasks → Generate scripts..."). During this process there'll be a step called "Set Scripting Options", where you'll have to click the "Advanced" button and carefully go through the options. You'll definitely want to choose "Data and schema" for the option "Types of data to script". I sometimes prefer this method if I really just want the data structures and the data itself to be transferred.
Update: Sorry, I forgot to mention how to restore the database for the scripting option. I always generate the scripts by selecting "Save to new query window" during the "Set Scripting Options" step. After the script is generated, just leave it there for a moment.
On the target server create a new database with the same name as the one you generated the scripts for. Or you can create a script for that on the source server, too (right-click the database, choose "Script Database as → CREATE TO... → Clipboard") and execute this script by right-clicking the server node in the SSMS Object Explorer, selecting "New query", pasting the script into the query window and executing it. This second option is the better choice if you really need a complete copy of the database and not just the data itself.
Once you've gone down one of these two roads you should have created a new database. Right-click this database in Object Explorer and select "New Query", then copy and paste the script containing the database structure and data into the new query window and execute the query. This should do the trick.
edited Sep 18 '13 at 8:47
answered Sep 18 '13 at 7:55
Onkel ToobOnkel Toob
1,40811021
1,40811021
how to restore generated script into another machine
– DK007
Sep 18 '13 at 8:31
@DK007 I updated my answer.
– Onkel Toob
Sep 18 '13 at 8:47
add a comment |
how to restore generated script into another machine
– DK007
Sep 18 '13 at 8:31
@DK007 I updated my answer.
– Onkel Toob
Sep 18 '13 at 8:47
how to restore generated script into another machine
– DK007
Sep 18 '13 at 8:31
how to restore generated script into another machine
– DK007
Sep 18 '13 at 8:31
@DK007 I updated my answer.
– Onkel Toob
Sep 18 '13 at 8:47
@DK007 I updated my answer.
– Onkel Toob
Sep 18 '13 at 8:47
add a comment |
You can't copy Database to another machine.
Yes you can take back up to same machine and copy it to another machine and do restore.
To take backup follow procedure:
- Right Click on the database you want to take backup.
- Choose Task -> Back Up.
- In Destination, Choose Add.
- In File Name click on
...
button and choose destination folder where you want to backup with backupname.bak . Click Ok, Ok and Ok. and wait until backup process is completed. Click Ok.
Now copy that backup file into pendrive or any media and paste it to another machine and Open SQL Server 2008 R2
To restore backup follow procedure:
- Right Click on the Databases.
- Choose Restore Database.
- Write database name which you want to restore in To Database field
- Select From device radio button in Source for restore. Click on
...
- Click on Add button, Select database backup file you have pasted. Click Ok, Ok.
- Check the checkbox of Restore in Select the beckup sets to restore.
- Go on Options Check Overwrite the existing database & Preserve the replication settings (this fields needed to check only when you try to restore database which is already resided on that another device)
- Click Ok. wait until restore complete and click ok.
Tell me if you face any problem.
By Code
To Backup:
USE DATABASE_NAME;
GO
BACKUP DATABASE DATABASE_NAME
TO DISK = 'D:DATABASE_NAME.Bak'
WITH FORMAT, MEDIANAME = 'D_SQLServerBackups',
NAME = 'Full Backup of DATABASE_NAME';
GO
(If you want to put backup in any folder, the folder must be exist before you take the backup.)
To Restore:
Step 1: Retrive the Logical file name of the database from backup.
RESTORE FILELISTONLY
FROM DISK = 'D:BackUpYourBaackUpFile.bak'
GO
Step 2: Use the values in the LogicalName Column in following Step.
----Make Database to single user Mode
ALTER DATABASE YourDB
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE
----Restore Database
RESTORE DATABASE YourDB
FROM DISK = 'D:BackUpYourBaackUpFile.bak'
WITH MOVE 'YourMDFLogicalName' TO 'D:DataYourMDFFile.mdf',
MOVE 'YourLDFLogicalName' TO 'D:DataYourLDFFile.ldf'
/If there is no error in statement before database will be in multiuser
mode.
If error occurs please execute following command it will convert
database in multi user./
ALTER DATABASE YourDB SET MULTI_USER
GO
1
+1, one remark: If the database is not present yet on the target machine, you can't right-click it in step 1 of the restore block. You can right-click the "Databases" folder, though and go from there.
– Onkel Toob
Sep 18 '13 at 8:10
add a comment |
You can't copy Database to another machine.
Yes you can take back up to same machine and copy it to another machine and do restore.
To take backup follow procedure:
- Right Click on the database you want to take backup.
- Choose Task -> Back Up.
- In Destination, Choose Add.
- In File Name click on
...
button and choose destination folder where you want to backup with backupname.bak . Click Ok, Ok and Ok. and wait until backup process is completed. Click Ok.
Now copy that backup file into pendrive or any media and paste it to another machine and Open SQL Server 2008 R2
To restore backup follow procedure:
- Right Click on the Databases.
- Choose Restore Database.
- Write database name which you want to restore in To Database field
- Select From device radio button in Source for restore. Click on
...
- Click on Add button, Select database backup file you have pasted. Click Ok, Ok.
- Check the checkbox of Restore in Select the beckup sets to restore.
- Go on Options Check Overwrite the existing database & Preserve the replication settings (this fields needed to check only when you try to restore database which is already resided on that another device)
- Click Ok. wait until restore complete and click ok.
Tell me if you face any problem.
By Code
To Backup:
USE DATABASE_NAME;
GO
BACKUP DATABASE DATABASE_NAME
TO DISK = 'D:DATABASE_NAME.Bak'
WITH FORMAT, MEDIANAME = 'D_SQLServerBackups',
NAME = 'Full Backup of DATABASE_NAME';
GO
(If you want to put backup in any folder, the folder must be exist before you take the backup.)
To Restore:
Step 1: Retrive the Logical file name of the database from backup.
RESTORE FILELISTONLY
FROM DISK = 'D:BackUpYourBaackUpFile.bak'
GO
Step 2: Use the values in the LogicalName Column in following Step.
----Make Database to single user Mode
ALTER DATABASE YourDB
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE
----Restore Database
RESTORE DATABASE YourDB
FROM DISK = 'D:BackUpYourBaackUpFile.bak'
WITH MOVE 'YourMDFLogicalName' TO 'D:DataYourMDFFile.mdf',
MOVE 'YourLDFLogicalName' TO 'D:DataYourLDFFile.ldf'
/If there is no error in statement before database will be in multiuser
mode.
If error occurs please execute following command it will convert
database in multi user./
ALTER DATABASE YourDB SET MULTI_USER
GO
1
+1, one remark: If the database is not present yet on the target machine, you can't right-click it in step 1 of the restore block. You can right-click the "Databases" folder, though and go from there.
– Onkel Toob
Sep 18 '13 at 8:10
add a comment |
You can't copy Database to another machine.
Yes you can take back up to same machine and copy it to another machine and do restore.
To take backup follow procedure:
- Right Click on the database you want to take backup.
- Choose Task -> Back Up.
- In Destination, Choose Add.
- In File Name click on
...
button and choose destination folder where you want to backup with backupname.bak . Click Ok, Ok and Ok. and wait until backup process is completed. Click Ok.
Now copy that backup file into pendrive or any media and paste it to another machine and Open SQL Server 2008 R2
To restore backup follow procedure:
- Right Click on the Databases.
- Choose Restore Database.
- Write database name which you want to restore in To Database field
- Select From device radio button in Source for restore. Click on
...
- Click on Add button, Select database backup file you have pasted. Click Ok, Ok.
- Check the checkbox of Restore in Select the beckup sets to restore.
- Go on Options Check Overwrite the existing database & Preserve the replication settings (this fields needed to check only when you try to restore database which is already resided on that another device)
- Click Ok. wait until restore complete and click ok.
Tell me if you face any problem.
By Code
To Backup:
USE DATABASE_NAME;
GO
BACKUP DATABASE DATABASE_NAME
TO DISK = 'D:DATABASE_NAME.Bak'
WITH FORMAT, MEDIANAME = 'D_SQLServerBackups',
NAME = 'Full Backup of DATABASE_NAME';
GO
(If you want to put backup in any folder, the folder must be exist before you take the backup.)
To Restore:
Step 1: Retrive the Logical file name of the database from backup.
RESTORE FILELISTONLY
FROM DISK = 'D:BackUpYourBaackUpFile.bak'
GO
Step 2: Use the values in the LogicalName Column in following Step.
----Make Database to single user Mode
ALTER DATABASE YourDB
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE
----Restore Database
RESTORE DATABASE YourDB
FROM DISK = 'D:BackUpYourBaackUpFile.bak'
WITH MOVE 'YourMDFLogicalName' TO 'D:DataYourMDFFile.mdf',
MOVE 'YourLDFLogicalName' TO 'D:DataYourLDFFile.ldf'
/If there is no error in statement before database will be in multiuser
mode.
If error occurs please execute following command it will convert
database in multi user./
ALTER DATABASE YourDB SET MULTI_USER
GO
You can't copy Database to another machine.
Yes you can take back up to same machine and copy it to another machine and do restore.
To take backup follow procedure:
- Right Click on the database you want to take backup.
- Choose Task -> Back Up.
- In Destination, Choose Add.
- In File Name click on
...
button and choose destination folder where you want to backup with backupname.bak . Click Ok, Ok and Ok. and wait until backup process is completed. Click Ok.
Now copy that backup file into pendrive or any media and paste it to another machine and Open SQL Server 2008 R2
To restore backup follow procedure:
- Right Click on the Databases.
- Choose Restore Database.
- Write database name which you want to restore in To Database field
- Select From device radio button in Source for restore. Click on
...
- Click on Add button, Select database backup file you have pasted. Click Ok, Ok.
- Check the checkbox of Restore in Select the beckup sets to restore.
- Go on Options Check Overwrite the existing database & Preserve the replication settings (this fields needed to check only when you try to restore database which is already resided on that another device)
- Click Ok. wait until restore complete and click ok.
Tell me if you face any problem.
By Code
To Backup:
USE DATABASE_NAME;
GO
BACKUP DATABASE DATABASE_NAME
TO DISK = 'D:DATABASE_NAME.Bak'
WITH FORMAT, MEDIANAME = 'D_SQLServerBackups',
NAME = 'Full Backup of DATABASE_NAME';
GO
(If you want to put backup in any folder, the folder must be exist before you take the backup.)
To Restore:
Step 1: Retrive the Logical file name of the database from backup.
RESTORE FILELISTONLY
FROM DISK = 'D:BackUpYourBaackUpFile.bak'
GO
Step 2: Use the values in the LogicalName Column in following Step.
----Make Database to single user Mode
ALTER DATABASE YourDB
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE
----Restore Database
RESTORE DATABASE YourDB
FROM DISK = 'D:BackUpYourBaackUpFile.bak'
WITH MOVE 'YourMDFLogicalName' TO 'D:DataYourMDFFile.mdf',
MOVE 'YourLDFLogicalName' TO 'D:DataYourLDFFile.ldf'
/If there is no error in statement before database will be in multiuser
mode.
If error occurs please execute following command it will convert
database in multi user./
ALTER DATABASE YourDB SET MULTI_USER
GO
edited Sep 18 '13 at 8:45
answered Sep 18 '13 at 8:01
DhwaniDhwani
4,0591256121
4,0591256121
1
+1, one remark: If the database is not present yet on the target machine, you can't right-click it in step 1 of the restore block. You can right-click the "Databases" folder, though and go from there.
– Onkel Toob
Sep 18 '13 at 8:10
add a comment |
1
+1, one remark: If the database is not present yet on the target machine, you can't right-click it in step 1 of the restore block. You can right-click the "Databases" folder, though and go from there.
– Onkel Toob
Sep 18 '13 at 8:10
1
1
+1, one remark: If the database is not present yet on the target machine, you can't right-click it in step 1 of the restore block. You can right-click the "Databases" folder, though and go from there.
– Onkel Toob
Sep 18 '13 at 8:10
+1, one remark: If the database is not present yet on the target machine, you can't right-click it in step 1 of the restore block. You can right-click the "Databases" folder, though and go from there.
– Onkel Toob
Sep 18 '13 at 8:10
add a comment |
Copying a database using a full database backup will not copy the transactions in the online transaction log.
If this is important, use the following steps to take the database offline, copy the MDF and LDF files, and attach them:
- Select the database in SQL Server Management Studio , right-click the database and select Properties. Copy the location of the MDF and LDF files
2.Click OK
3.Right-click the database again, select Tasks, Take offline
4.In Windows Explorer, copy the MDF and LDF files using the location found in step #1
5.Paste them to another location
6.In SQL Server Management Studio right-click the SQL Server instance and select Attach
7.In the next dialog, click Add, find the copied files, select them and click OK
8.Change the default name offered in the Attach AS field. Specify the new name you want for your database here.
9.Click OK
To bring back online the original database, right-click it and select Tasks, Bring online
add a comment |
Copying a database using a full database backup will not copy the transactions in the online transaction log.
If this is important, use the following steps to take the database offline, copy the MDF and LDF files, and attach them:
- Select the database in SQL Server Management Studio , right-click the database and select Properties. Copy the location of the MDF and LDF files
2.Click OK
3.Right-click the database again, select Tasks, Take offline
4.In Windows Explorer, copy the MDF and LDF files using the location found in step #1
5.Paste them to another location
6.In SQL Server Management Studio right-click the SQL Server instance and select Attach
7.In the next dialog, click Add, find the copied files, select them and click OK
8.Change the default name offered in the Attach AS field. Specify the new name you want for your database here.
9.Click OK
To bring back online the original database, right-click it and select Tasks, Bring online
add a comment |
Copying a database using a full database backup will not copy the transactions in the online transaction log.
If this is important, use the following steps to take the database offline, copy the MDF and LDF files, and attach them:
- Select the database in SQL Server Management Studio , right-click the database and select Properties. Copy the location of the MDF and LDF files
2.Click OK
3.Right-click the database again, select Tasks, Take offline
4.In Windows Explorer, copy the MDF and LDF files using the location found in step #1
5.Paste them to another location
6.In SQL Server Management Studio right-click the SQL Server instance and select Attach
7.In the next dialog, click Add, find the copied files, select them and click OK
8.Change the default name offered in the Attach AS field. Specify the new name you want for your database here.
9.Click OK
To bring back online the original database, right-click it and select Tasks, Bring online
Copying a database using a full database backup will not copy the transactions in the online transaction log.
If this is important, use the following steps to take the database offline, copy the MDF and LDF files, and attach them:
- Select the database in SQL Server Management Studio , right-click the database and select Properties. Copy the location of the MDF and LDF files
2.Click OK
3.Right-click the database again, select Tasks, Take offline
4.In Windows Explorer, copy the MDF and LDF files using the location found in step #1
5.Paste them to another location
6.In SQL Server Management Studio right-click the SQL Server instance and select Attach
7.In the next dialog, click Add, find the copied files, select them and click OK
8.Change the default name offered in the Attach AS field. Specify the new name you want for your database here.
9.Click OK
To bring back online the original database, right-click it and select Tasks, Bring online
answered Jul 28 '14 at 16:46
Milena PetrovicMilena Petrovic
2,2361317
2,2361317
add a comment |
add a comment |
if you are copying it to a SQL 2008 R2 then all u have to do is
- open SQL server management studio
- choose your database
- right click, go to Tasks --> BackUp
- in the database backup window, click add and then give your backup path and file name
click ok
copy the backup file to any drive in the machine to which you want to restore then,
- Open SQL server management studio
- create a new database
- right click on the newly created database, go to Tasks --> Restore --> Database
- on the restore window select from device option
- add the backup file path
- click ok
add a comment |
if you are copying it to a SQL 2008 R2 then all u have to do is
- open SQL server management studio
- choose your database
- right click, go to Tasks --> BackUp
- in the database backup window, click add and then give your backup path and file name
click ok
copy the backup file to any drive in the machine to which you want to restore then,
- Open SQL server management studio
- create a new database
- right click on the newly created database, go to Tasks --> Restore --> Database
- on the restore window select from device option
- add the backup file path
- click ok
add a comment |
if you are copying it to a SQL 2008 R2 then all u have to do is
- open SQL server management studio
- choose your database
- right click, go to Tasks --> BackUp
- in the database backup window, click add and then give your backup path and file name
click ok
copy the backup file to any drive in the machine to which you want to restore then,
- Open SQL server management studio
- create a new database
- right click on the newly created database, go to Tasks --> Restore --> Database
- on the restore window select from device option
- add the backup file path
- click ok
if you are copying it to a SQL 2008 R2 then all u have to do is
- open SQL server management studio
- choose your database
- right click, go to Tasks --> BackUp
- in the database backup window, click add and then give your backup path and file name
click ok
copy the backup file to any drive in the machine to which you want to restore then,
- Open SQL server management studio
- create a new database
- right click on the newly created database, go to Tasks --> Restore --> Database
- on the restore window select from device option
- add the backup file path
- click ok
edited Sep 18 '13 at 9:20
answered Sep 18 '13 at 9:11
Kiran M RKiran M R
767
767
add a comment |
add a comment |
Justin's answer above was almost correct, it is simply right click on database in SSMS and select "Tasks" > "Export Data". This wizard allows you to duplicate the entire database to another location.
add a comment |
Justin's answer above was almost correct, it is simply right click on database in SSMS and select "Tasks" > "Export Data". This wizard allows you to duplicate the entire database to another location.
add a comment |
Justin's answer above was almost correct, it is simply right click on database in SSMS and select "Tasks" > "Export Data". This wizard allows you to duplicate the entire database to another location.
Justin's answer above was almost correct, it is simply right click on database in SSMS and select "Tasks" > "Export Data". This wizard allows you to duplicate the entire database to another location.
answered Mar 2 '18 at 20:50
DerekDerek
111
111
add a comment |
add a comment |
In addition for copy or move database to another server in same network level you can use SQL Server Copy Database Wizard
for use this method you should
- Right click on database
- Select task and
- Select copy database
- Fill source database server login data
- Fill destination database server login data
- Select transfer method
- Select databases to transfer(except system databases)
Extra description about this method
add a comment |
In addition for copy or move database to another server in same network level you can use SQL Server Copy Database Wizard
for use this method you should
- Right click on database
- Select task and
- Select copy database
- Fill source database server login data
- Fill destination database server login data
- Select transfer method
- Select databases to transfer(except system databases)
Extra description about this method
add a comment |
In addition for copy or move database to another server in same network level you can use SQL Server Copy Database Wizard
for use this method you should
- Right click on database
- Select task and
- Select copy database
- Fill source database server login data
- Fill destination database server login data
- Select transfer method
- Select databases to transfer(except system databases)
Extra description about this method
In addition for copy or move database to another server in same network level you can use SQL Server Copy Database Wizard
for use this method you should
- Right click on database
- Select task and
- Select copy database
- Fill source database server login data
- Fill destination database server login data
- Select transfer method
- Select databases to transfer(except system databases)
Extra description about this method
answered Nov 15 '18 at 13:25
Hamed NaeemaeiHamed Naeemaei
39028
39028
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f18866321%2fhow-to-copy-sql-server-2008-r2-database-from-one-machine-to-another%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Have you tried a few searches, surely there is already resource out there for this?
– JsonStatham
Sep 18 '13 at 7:42
2
just take a backup of the database and restore it to the other machine - technet.microsoft.com/en-us/library/ms186390.aspx
– NDJ
Sep 18 '13 at 7:44
I have already made a search but didn't get proper answer
– DK007
Sep 18 '13 at 7:48
please tell me step that how to make backup and restore
– DK007
Sep 18 '13 at 7:52
easiest way select the database in the source server in SSMS Right click ->Tasks->Copy Database Wizard to launch the copy database wizard.
– Justin
Sep 18 '13 at 8:04