Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Detaching non-existing db's

Author  Topic 

knifebright
Starting Member

4 Posts

Posted - 2006-01-09 : 04:54:46
Hello all

From time to time I receive mssql server databases to export from our customers. Last time I deleted the database files without detaching them. How can I detached them, since I need to atach new ones with the same name?
I'm using MS SQL Server 2003 and the databases are 6.5.

Thank you all.

Regards.

shallu1_gupta
Constraint Violating Yak Guru

394 Posts

Posted - 2006-01-09 : 04:58:59
Hi,
use sp_detach_db 'dbname' ,'skipchecks= true or false
Go to Top of Page

knifebright
Starting Member

4 Posts

Posted - 2006-01-09 : 05:44:52
Hello shallu1_gupta

That line doesn't work in this case. SQL Server replies

"Msg 945, Level 14, State 2, Line 1
Database 'dbname' cannot be opened due to inaccessible files or insufficient memory or disk space."

Thanks, anyway.

Regards
Go to Top of Page

shallu1_gupta
Constraint Violating Yak Guru

394 Posts

Posted - 2006-01-09 : 06:39:10
oops i missed that you have already deleted the database files. It might be showing the status of DB as suspect in Enterprise Manager.
Go to Top of Page

knifebright
Starting Member

4 Posts

Posted - 2006-01-10 : 10:46:01
Hello

On SQL Server Manager 2005 I can't detach the databases.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-01-10 : 11:43:28
Try this:

use master

DROP DATABASE your_database_name






CODO ERGO SUM
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-01-10 : 23:59:28
should you take the road towards dropping the dbs, I suggest you do the following first just incase you might the files later:

take them offline first,
copy the files to another location
take them online
or

as an alternative, perform backups

--------------------
keeping it simple...
Go to Top of Page

knifebright
Starting Member

4 Posts

Posted - 2006-01-11 : 06:48:46
Hello all,

DROP DATABASE worked just fine! :D

Thank you all.

Regards
Go to Top of Page
   

- Advertisement -