I would like to be able to write a simple script to be able to drop a localdb database at will.
First I have to stop the instance to kill any active connections by running this in the VS package manager
SqlLocalDB.exe stop v11.0
Then I need to drop the db which I have to do by connecting to (localdb)\v11.0
master db with Linqpad or SSMS
DROP DATABASE MyDb
But I don't want to switch windows to do this, I'd like to just write a script. I can't figure out how to execute the second query from the command line. I've tried this
SQLCMD.EXE -s "(localdb)\v11.0" -d "master" -q "drop database MyDb"
which gives me an error
SQLCMD.EXE : Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider:
Could not open a connection to SQL Server [2]. .