delete data/log files when not in use?

  • One thing I came across today...

    When SQL Server is running and no sql activity is being done on any of the databases, any one with delete rights can delete the mdf/ldf files?

    I was under the impression that sql server does not allow to delete/move the data/log files of the databases attached to it!!!

    I do understand that the rights are applied by the OS and not the SQL Server.

    But still can the data/log files be deleted when not in use?

    Sachin


    Regards,
    Sachin Dedhia

  • alter database pubs remove file pubs_data2. For details, see BOL.

    Make sure the file you are going to remove is empty.

  • I'm not sure if I understand the question correctly, but when the SQL Server service is running, it locks the physical files so that no one can delete/alter the files through the OS (eg windows explorer). This is true, I believe, even when there is no activity within SQL Server itself.

    However, if the SQL Server service is not running then anyone can delete/rename the files through the OS (assuming that they have appropriate OS permission to do so).

    Jeremy

  • You can also modify the file name or even delete it when the database is offline

    No matter if services run or not

    Frank

    http://www.insidesql.de

    http://www.familienzirkus.de

    Edited by - Frank kalis on 11/28/2003 07:50:52 AM

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • If you have a database set to AUTOCLOSE (the default for SQL Personal Edition, but needing to be explicitly set for other editions) then yes, when the last user has disconnected, the mdf/ldf files will be closed and available for anyone with appropriate permissions to manipulate.

    Cheers,

    - Mark


    Cheers,
    - Mark

  • Thanks Mark, it works. Previously I did not get any such problem. But now I am working on Personal Edition and Desktop Edition (MSDE) and as u say....

    Sachin

    🙂


    Regards,
    Sachin Dedhia

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

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