Home All Groups Group Topic Archive Search About
Author
17 Feb 2006 9:25 AM
chris
Hello,

in our project i have to drop an existing sql server database and
immediately create a new (and empty) one with exactly the same name. MSDN
says that in case of dropping a database also the physical files on the
harddrive are deleted but this is not the case, as sql server complains that
there's already a file with that name on disk.
Is there a way to delete also the disk files of a database using T-SQL or do
i have to choose a different approach?

Thanks in advance
Christian

Author
17 Feb 2006 9:55 AM
Tibor Karaszi
In 6.5 and older, the database files were not deleted when you execute DROP DATABASE. As of 7.0,
they are. If you are seeing something different, you have either hit a bug in the product (unlikely)
or may have some problems in your scripts.

Show quote
"chris" <ch***@discussions.microsoft.com> wrote in message
news:68AFCD1C-85B6-4661-9332-3F50830BF386@microsoft.com...
> Hello,
>
> in our project i have to drop an existing sql server database and
> immediately create a new (and empty) one with exactly the same name. MSDN
> says that in case of dropping a database also the physical files on the
> harddrive are deleted but this is not the case, as sql server complains that
> there's already a file with that name on disk.
> Is there a way to delete also the disk files of a database using T-SQL or do
> i have to choose a different approach?
>
> Thanks in advance
> Christian
Author
17 Feb 2006 10:07 AM
ML
Check the default file location. Could it be that you previously created a
database with the same name in this location, but later abandoned it and
started creating databases with files in another location while the default
file location was left unchanged?

The easiest way would be to check your default location and check your file
system.


ML

---
http://milambda.blogspot.com/
Author
17 Feb 2006 10:51 AM
chris
Thank you very much for your replies.
I found that before dropping the database it was set OFFLINE to disconnect
users and in this case the files remain on disk. I set it to SINGLE_USER
instead and then it worked.

Chris

Show quote
"chris" wrote:

> Hello,
>
> in our project i have to drop an existing sql server database and
> immediately create a new (and empty) one with exactly the same name. MSDN
> says that in case of dropping a database also the physical files on the
> harddrive are deleted but this is not the case, as sql server complains that
> there's already a file with that name on disk.
> Is there a way to delete also the disk files of a database using T-SQL or do
> i have to choose a different approach?
>
> Thanks in advance
> Christian
Author
17 Feb 2006 11:09 AM
Tibor Karaszi
> I found that before dropping the database it was set OFFLINE to disconnect
> users and in this case the files remain on disk.

That was news for me. Thanks for sharing the information, Chris.

Show quote
"chris" <ch***@discussions.microsoft.com> wrote in message
news:B5951FCB-2434-4241-969C-02BF0E7816A3@microsoft.com...
> Thank you very much for your replies.
> I found that before dropping the database it was set OFFLINE to disconnect
> users and in this case the files remain on disk. I set it to SINGLE_USER
> instead and then it worked.
>
> Chris
>
> "chris" wrote:
>
>> Hello,
>>
>> in our project i have to drop an existing sql server database and
>> immediately create a new (and empty) one with exactly the same name. MSDN
>> says that in case of dropping a database also the physical files on the
>> harddrive are deleted but this is not the case, as sql server complains that
>> there's already a file with that name on disk.
>> Is there a way to delete also the disk files of a database using T-SQL or do
>> i have to choose a different approach?
>>
>> Thanks in advance
>> Christian

AddThis Social Bookmark Button