I installed a trading software that uses pair specified and gives me details about it. For initiating the software I have to create a database that it uses to store and retrieve information from. Now I have deleted the database(mdf and ldf file) and now when I create it again it shows that database already exists error. Do I have to delete DSN or something? I can do create database using another sql server instance, but I want to do on the same one. I am clueless. Thanks in advance.
Asked
Active
Viewed 1.9k times
6
-
What version of SQL Server are you using? If you deleted the files outside of SQL Server (the wrong way of dropping a database btw) the server still thinks the database exists and is in error. Try issuing a `drop database name_of_the_db` in the management console. – jpw Feb 14 '14 at 07:20
-
SQL server 2008 express edition. So, this cannot be done without management tools? – Aman Chhabra Feb 14 '14 at 07:22
3 Answers
6
The database information is maintained by sql server express. So just deleting the file doesn't remove the database from sql server. You need to detach the database and then your logic should work. Try sql server management studio express 2008. Or try connect to sql server express programmatically and execute sp_detach_db permissions.
Source : MSDN

Mogli
- 1,972
- 11
- 34
- 67
-
Any possible way to do this without management tools? I am running sql server 2008 express. – Aman Chhabra Feb 14 '14 at 07:24
-
1http://stackoverflow.com/questions/3210138/need-to-create-new-database-without-using-management-studio might help you. – Mogli Feb 14 '14 at 07:32
5
A Database is not only MDF and LDF files but also a record in the master database. So you should drop this record about your DB using DROP DATABASE command or through MSSQL Enterprise Manager.

valex
- 23,966
- 7
- 43
- 60
-
I am running SQL server 2008 express edition. So, this cannot be done without management tools? – Aman Chhabra Feb 14 '14 at 07:23
-
1@AmanChhabra Check this link [How to delete a database with SQL Server 2008 Express](http://social.msdn.microsoft.com/Forums/sqlserver/en-US/fa11753e-ee78-46e4-9fb4-d8eedc3874a9/how-to-delete-a-database-with-sql-server-2008-express-installed) – valex Feb 14 '14 at 07:25