Sandy
Sandy

Reputation: 11687

How to delete Sql Server Database

I created a database using Server Explorer Visual Studio of name MyDatabase.mdf (and MyDatabase.ldf). Now i want to delete it.I deleted it from Visual Studio using Server Explorer (means removed reference). Then i deleted MyDatabase.mdf and MyDatabase.ldf files from my C directory (C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL). But when i try creating a new database with same name (MyDatabase), it gives an error and says, database name already exists, try some other name.

Upvotes: 0

Views: 4787

Answers (2)

Kiley Naro
Kiley Naro

Reputation: 1769

There are probably metabase attributes still left in your master table referencing your deleted tables. Instead of just deleting the MDF and LDF files, I would recommend using T-SQL DROP DATABASE statements. If you have MS SQL Management Studio, you could also right-click on your database and choose the "Delete" option.

Upvotes: 2

Wil
Wil

Reputation: 4270

Are you creating a User Instance of the database? If so, remove the "Initial Catalog" parameter from the connection string in the solution in Visual Studio if you have it defined.

Upvotes: 0

Related Questions