Can I use SqlCmd to run scripts in the localdb database?

I have a large SQL script (1gb) that I am trying to execute with an instance (localdb)\v11.0 using SqlCmd in a command window, but so far no commands I tried worked with it at all.

eg.

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

general connection error failure:

There was a network-related or specific instance error while establishing a connection to SQL Server. Server not found or unavailable. Verify that the instance name is correct and if SQL Server is configured to allow remote connections.

However

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

works fine with an instance of SQL Server on my PC.

“Allow remote connections” is set to true on the instance (localdb) , and the user I'm running SqlCmd with is its owner.

Does SqlCmd work with instances (localdb) ? Are there other obvious things that I can do wrong?

+5
source share
2 answers

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

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

Hth, ojf

+2
source

Change the 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"

0
source

All Articles