开发者

how to drop user defined database in sql server 2005?

I am trying to drop a user-defined database, like so:

create database demo;
drop database demo;

But I get the error

Cannot drop the database 'demo', 开发者_如何学Pythonbecause it does not exist or you do not have permission.


One way to sort this out might be to run

SELECT name FROM sys.databases

to see if the database does exist.

Some helpful tips from MSDN:

  • To use DROP DATABASE, the database context of the connection cannot be the same as the database to be dropped. You could change your context to, for example USE master before running DROP
  • To execute DROP DATABASE, at a minimum, a user must have CONTROL permission on the database.

You might find some other useful information there that applies to your specific situation.


create database demo;
drop database demo;

In the above code, if the database is deleted and again tried to delete the database which does not exists will give you the error as you mentioned

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜