Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
hima1
Starting Member
2 Posts |
Posted - 2013-05-07 : 16:22:22
|
Hi, I am trying to restore a db of 6GB using the command line but do not know how to do that. Could someone help me with the instructions and commands in doing that. Thanks in advance. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-05-07 : 17:08:14
|
The most basic would be something like this:RESTORE DATABASE [TestDatabase] FROM DISK = N'C:\Backups\YourDatabase.bak' However, don't use that. Instead, go to SSMS, right click on databases and select Restore Database. Go through the dialogs and set up everything the way that you want to. Then instead of clicking the OK button, click the "Script" button at the top left of the right-panel. That will generate the script that would have been used had you clicked the OK button. Take that script, examine it, modify it if you need to, and use that. |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2013-05-07 : 18:01:17
|
You can use the statement James provided on the Windows command line using the sqlcmd utility. Details here: http://msdn.microsoft.com/en-us/library/ms162773.aspxUse the -Q, -q or -i flags (the latter must use a SQL file with the commands in it) |
|
|
hima1
Starting Member
2 Posts |
Posted - 2013-05-10 : 13:22:01
|
I get the below error when I did this:C:\>RESTORE DATABASE [hima] FROM DISK = N'C:\hima\hima.bak' -q'RESTORE' is not recognized as an internal or external command,operable program or batch file.The reason for doing it through command line is I was not able to restore from SSMS, was getting an error there, Hence was trying of doing that through command line as an alternative approach. |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2013-05-10 : 13:25:11
|
SQLCMD -S servername -E -Q"RESTORE DATABASE [hima] FROM DISK = N'C:\hima\hima.bak'" |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2013-05-10 : 13:40:38
|
What error - were you getting through SSMS?Jack Vamvas--------------------http://www.sqlserver-dba.com |
|
|
|
|
|
|
|