Restore a databse when in Use

  • HI

    is there a way to restore the database when in Use

    instead of asking the users to exit from the server

    i mean sometimes when i try to restore a database it errors out saying database is in use....

    iam trying to restore the database from a disk

  • if you just want to kick everybody out user alter database

    alter database xyz set single_user with rollback immediate;

    restore database xyz

    ...

    keep in mind NOT to place a "go" in between both lines

    - or in some cases you may not be the one actualy having

    access to the database.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • I think he also needs to execute this to get database back to multi user mode.

    USE [master]

    GO

    ALTER DATABASE [xyz] SET MULTI_USER WITH ROLLBACK IMMEDIATE

    GO

    ALTER DATABASE [xyz] SET MULTI_USER

    GO

    SQL DBA.

  • $sanjayattray (3/11/2008)


    I think he also needs to execute this to get database back to multi user mode.

    USE [master]

    GO

    ALTER DATABASE [xyz] SET MULTI_USER WITH ROLLBACK IMMEDIATE

    GO

    ALTER DATABASE [xyz] SET MULTI_USER

    GO

    The database will be restored in with the same set of settings at the

    time is has been backed up.

    So if it was multi multi user at backup time, it will be multi user after

    restore (with recovery).

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply