Automatic Offline Script

  • how can i go about creating a script that will take a particular database offline when a we get to a certain date


    Everything you can imagine is real.

  • Create a scheduled job to run sp_detach_db and set it to run once at the designated date/time, plus set it to delete if successful if you do not want to keep the job

    Far away is close at hand in the images of elsewhere.
    Anon.

  • thanks


    Everything you can imagine is real.

  • a few more points to ponder ...

    Taking the database 'offline' via attach does not delete the underlying .mdf/.ldf/.ndf files. Unless you manage those files you may have disk space issues in the future. If you utilized drop database (after making a complete backup for archival) then the underlying file issue is solved. Some more food for though ... maintenance plans, backup directory(s) (full and transactional) other SQL jobs/tasks will also probably have to be touched or removed.

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

  • And Dettaching (in my opinion) is something different from set it offline like:

    Alter database dbname SET OFFLINE WITH ROLLBACK IMMEDIATE, NO_WAIT

    That, is what I call to set it offline

     


    * Noel

  • agreed !

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

Viewing 6 posts - 1 through 5 (of 5 total)

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