SQL SERVER – Error: Deleting Offline Database and Creating the Same Name

Offline database is very interesting subject, and there are a couple of interesting details associated with it, which one must know.

There are two common queries related to offline database:

1)      My hard drive is getting full and I deleted my ‘offline’ databases. After deleting my offline databases, my hard drive is still full and there is no empty space.

2)      I recently deleted the ‘offline’ database, and now, when I am attempting to create database with the same name, it is giving me error that the database file already exists.

I can see why these questions are coming up frequently. The common understanding that seems to prevail is that when any database is deleted, files associated with the database (.mdf, .ndf and .ldf) are deleted automatically. This is true for any database that is an ‘online’ database. However, the behavior is bit different in the case of the ‘offline’ database. When any ‘offline’ database is deleted, files associated with the database are not deleted automatically. All the files related to the ‘offline’ database need to be deleted manually after deleting the offline database.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

9 thoughts on “SQL SERVER – Error: Deleting Offline Database and Creating the Same Name

  1. Once my manger asked me to delete offline database’s to free the space…..but target was not achieved…..now i understand why i wasn’t successful…Thanks…

    Like

  2. Can you please explain a bit further as to what are those files. I have made a sample program where I am attempting to create a new database using C#. Routine involves checking if file exists, and deleting the file if that is true, thereafter it attempts to create the database again. Interestingly the routine succeeds on its first attempt but fails when I try using the same database again, even though the database files have been deleted.

    Like

  3. Pingback: SQL SERVER – Weekly Series – Memory Lane – #006 « SQL Server Journey with SQL Authority

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s