Drop a SQL Server Database

Answered

I'm developing with a local SQL Server database.  I'm working on data migrations, so I'm frequently running a migration, then dropping the db, and repeating

Question:  When I try to use datagrip to drop the db, it always fails, indicating that there are connections to the db.  However, the connection is Datagrip itself.  So right now, I have to close datagrip, and use another tool like sqlcmd or ssms to do it.  How do I drop db using Datagrip?

0
5 comments

Jeremy Marsch,

It could be a bit tricky.

You no need to close DataGrip. You just need to Close All Sessions for the database (see Services) and after that you can easily drop database.

 

0

It would be nice if DataGrip could close the database connection by itself before dropping. SSMS has the corresponding check box:

0

Hi Urs Meili,

We have created a feature request to implement this functionality:

https://youtrack.jetbrains.com/issue/DBE-17374

Please feel free to upvote so it can get more attention.

0

I'm using LocalDB at the moment. 

It doesn't work, unfortunately. 

The moment I drop, it opens a new session.

It is one of the few things I need to fire SSMS up for. It is annoying from a UX perspective. :/

0
Hi Melle,

Do you mean that a new session is initiated when you drop an object in your IDE? Have you tried sticking to Single User Session option in the data source properties?

https://www.jetbrains.com/help/datagrip/configuring-database-connections.html#enable-single-session-mode
0

Please sign in to leave a comment.