June 29, 2009 at 6:14 am
Hello World,
I write a "log shipping" between two SQL Server 2008 Express.
This application is write in SMO, C#, .NET 3.5SP1.
I search how can i do in SMO to write the Transact SQL : "RESTORE DATABASE
Because, when i use Restore SMO Object, i receive an exception with "Device missing".
Please help me
Thanxs a lot.
June 29, 2009 at 6:23 am
you'll want to read up on RESTORE from Books online; if you are restoring from a file, the command would look something like this:
RESTORE DATABASE [YOURDB]
FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\YOURDB.bak'
WITH FILE = 1,
NOUNLOAD,
STATS = 10,
RECOVERY
GO
no need to include "RECOVERY", as it is the default if not specified, but I included it here for reference.
Lowell
June 29, 2009 at 6:32 am
I want to write in SMO the "RESTORE DATABASE myDatabase WITH RECOVERY". It's for my database backup began the main database.
ref. here : http://msdn.microsoft.com/en-us/library/ms188696.aspx
I difficult for me to explain correctly because my English is poor (I'm French) 😀
thanxs for your answers
:w00t:
June 29, 2009 at 6:37 am
RESTORE DATABASE myDatabase WITH RECOVERY would work only if there is already a backup in place and you want to restore the default backup. if this is on a diffrerent server, you need more information, similar to what I had posted.
because you said you were trying your own version of "log shipping", i inferred that you wre restoring the database on a different server, in order to have two databases ready for log shipping.
Lowell
June 29, 2009 at 6:45 am
yes, two SQL Express 2008 servers :
I have One Main Server, i copy and transfert via WCF, the log files on the second server.
on the second server (backup), i restore log file.
til here no problem.
If my main server crash, i want with smo, the backup server become the main server with "restore database mydb with recovery".
i hope my explain is correct.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply