Restore database without restoring data

  • 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 WITH RECOVERY ?

    Because, when i use Restore SMO Object, i receive an exception with "Device missing".

    Please help me

    Thanxs a lot.

  • 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • 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:

  • 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • 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