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...
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"