Is it possible to use SqlCmd to run scripts against a localdb database?

I've got a large SQL script (1gb) that I'm trying to run against a (localdb)\v11.0 instance, using SqlCmd in a command line window, but so far no commands I've tried have worked with it at all.


sqlcmd.exe -S "(localdb)\v11.0" -Q "select 1"

fails with a generic connection error:

A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections.


sqlcmd.exe -S "MY-PC" -Q "select 1"

is fine with the SQL Server instance on my PC.

"Allow Remote Connections" is set to true on the (localdb) instance and the user I'm running the sqlcmd with is the owner of it.

Does Sqlcmd actually work with (localdb) instances? Are there any other obvious things I might be doing wrong?


I believe this can happen when you use the wrong version of SQLCMD for the LocalDB instance as described in this post...

Why can't I connect to a SQL Server 2012 LocalDB shared instance?

Hth, Ojf

Change your working folder to C:\Program Files\Microsoft SQL Server\110\Tools\Binn

cd "C:\Program Files\Microsoft SQL Server\110\Tools\Binn"

and try again...

sqlcmd.exe -S "MY-PC"

Need Your Help

Interface to exchange with jms

java interface jms

I'd like to exchange messages with a customer over a jms queue. Something like:

JavaScript - Using HTML5 Local Storage to store form data and to present it on the "Thank You" page

javascript html5 forms

On my website I have a Reservations page which is a form that a user fills out etc. and then JavaScript will validate it to see if it's okay before submission etc.