What's the best way to update a database...?

  • Hi.

    I need to update a database with an "automated task"..

    Has anyone experience with this job ?

    The update include:

    1) retrieve all users that use the database

    2) send a message to

    3) wait user for a disconnection from the database

    3) change the database state in single user mode

    4) do the update

    5) replace the multi user mode

    Do you know if there are specific stored procedure or this process is manual and under control of the database administrator ?

    Thanks in advance.

    Massimo

  • This is I think more of a manual process. You should be able to send email to users, but who says they are going to read it, or worse yet follow what is read.

    I suppose you could just forget the email ,and just kill the users, and then maybe you might be able to automate.

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • Lots of variables there, plus easy to miss an error or exception.

    The wait for a disconnection is the problem. I think there are scripts in the script library that are similar. Probably only want to give people some XX amount of time before just killing them.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

  • I say warn 'em in advance and kick 'em out.

    alter database <dbname> set single_user with rollback after 10 seconds

  • First, what are you needing to do? You may not need to even kick the users out. If you absolutely do then Dons piece will get them out but you will lose data potentially. I would aim for the send an email the day before and let them know the DB will be offline for use at a certain time then try building a NET SEND message for all logged in users to let them know when you are kicking them out. I saw a script on this once but cannot remember the name or any other details to find. You could also disable the network at the server and do your changes there.

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

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