Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    8

    Unhappy Unanswered: restore database using OSQL

    Dear Sir/Madam,

    Would you please help me to create a batch file to restore a database from a file located on a remote path to my MSDE installed on my workstation.

    the original database location was on the D drive on the server

    but when i want to restore it to my MSDE it will be in a different path which is C

    I want to create a command batch file by just double clicking on it, it will restore the database. (i want a forced restoration).

    Please proivde me with your help.

    Regards,

    HotBird

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Look up RESTORE DATABASE in BOL. It's all there.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  3. #3
    Join Date
    May 2004
    Posts
    8

    Lightbulb check this script please

    Please check this script is it runnable and right

    OSQL -U sa - P xxxx RESTORE DATABASE mydb FROM DISK = '\\195.xxx.xxx.xxx\dolphindata\30704'
    WITH REPLACE, MOVE 'mydb_Data' TO 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\mydb_Data.MDF',MOVE 'mydb_Log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\mydb_LOG.LDF' QUIT


    I put this script in a file called "restore.bat"

    Please advise me

    Thanks in advance
    HotBird
    Last edited by hotbird; 10-07-04 at 04:53.

  4. #4
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Surround your RESTORE...by quotation marks and loose QUIT:

    OSQL -U sa - P xxxx "RESTORE DATABASE mydb FROM DISK = '\\195.xxx.xxx.xxx\dolphindata\30704'
    WITH REPLACE, MOVE 'mydb_Data' TO 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\mydb_Data.MDF',MOVE 'mydb_Log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\mydb_LOG.LDF'"
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •