• After setting a db to offline it wont be available for a restore, however, you put all statements in a single transaction

    --Step1

    alter database <dbname>

    set offline

    with rollback immediate -- this is the part that kills the connections

    --Step2

    alter database <dbname> set online

    restore database <dbname> <restore parameters>

    Credit: This was actually given to me by an on call DBA. Nice alternative instead of having to shutdown IIS on all my web servers to do a db restore./b]