Skip to content

LocalDB connections #470

Open
Open

Description

Will go-sqlcmd support LocalDB connections on Windows? (Basically the equivalent to sqlcmd -S (localdb)\MSSQLLocalDB -E.)

On Windows I get the following error with the latest go-sqlcmd 1.4.0: "no named pipe instance matching 'MSSQLLOCALDB' returned from host '(localdb)'".

Activity

  1. stuartpa commented on Oct 20, 2023

    @stuartpa
    Collaborator

    It would be great to fix this. Is it something we need to fix in the underlying go-mssqldb driver?

  2. shueybubbles commented on Oct 20, 2023

    @shueybubbles
    Contributor

    I don't know if it needs to be in the driver. I think there's some logic needed to calculate the right pipe name to connect to.
    We'd probably only support automatic instances that are started externally.
    The documentation shows how you may be able to connect using go-sqlcmd today by doing the pipe name calculation yourself.

    eg np:\\.\pipe\LOCALDB#F365A78E\tsql\query

  3. stuartpa commented on Oct 24, 2023

    @stuartpa
    Collaborator
    C:\Program Files\Microsoft SQL Server\150\Tools\Binn>SqlLocalDB.exe info MSSQLLocalDB
    Name:               MSSQLLocalDb
    Version:            15.0.4153.1
    Shared name:
    Owner:              REDMOND\******
    Auto-create:        Yes
    State:              Running
    Last start time:    24/10/2023 06:15:04
    Instance pipe name: np:\\.\pipe\LOCALDB#4B62CD62\tsql\query
    
    C:\>sqlcmd -S np:\\.\pipe\LOCALDB#4B62CD62\tsql\query
    Access is denied.
    Access is denied.
    
    C:\>"C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\SQLCMD.EXE" -S np:\\.\pipe\LOCALDB#4B62CD62\tsql\query
    1>
    

    I get "Access Denied" when using the correct np (obtained from SqlLocalDB.exe) with go-sqlcmd. It works fine with the ODBC version.

  4. added this to the Backlog milestone on Nov 28, 2023
  5. willsbctm commented on Dec 20, 2023

    @willsbctm

    I had to uninstall the sqlcmd go version and use sqlcmd ODBC version =(

    That's the solution (not good) that I found.

  6. weberms commented on Jul 28, 2024

    @weberms

    I'm having the same issue. When is this being pulled from backlog and fixed?

  7. iopaul commented on Dec 31, 2024

    @iopaul

    I'm having the same issue. any updates?

  8. shueybubbles commented on Dec 31, 2024

    @shueybubbles
    Contributor

    With 1.8.2 I am able to use the pipe name directly.

    10:24:23.79 e:\git\go-sqlcmd>sqllocaldb info mssqllocaldb
    Name:               MSSQLLocalDB
    Version:            15.0.4382.1
    Shared name:
    Owner:              redacted
    Auto-create:        Yes
    State:              Running
    Last start time:    12/31/2024 10:24:23 AM
    Instance pipe name: np:\\.\pipe\LOCALDB#6894F7B1\tsql\query
    
    (built from cmd\modern folder)
    10:25:10.12 e:\git\go-sqlcmd\cmd\modern>modern -S np:\\.\pipe\LOCALDB#6894F7B1\tsql\query
    1> select @@servername
    2> go
    
    --------------------------------------------------------------------------------------------------------------------------------
    redacted\LOCALDB#6894F7B1
    
    (1 row affected)
    1>
    

    It's a poor substitute but worth a try until we have time to address it.

  9. doggy8088 commented on Jun 16, 2025

    @doggy8088

    I really wish this bug can be fixed soon.

  10. yooakim commented on Jun 23, 2025

    @yooakim

    I also wish this can be fixed :-)

  11. aityahiaidir commented on Sep 19, 2025

    @aityahiaidir

    I have the same issue,

    With 1.8.2 I am able to use the pipe name directly.

    10:24:23.79 e:\git\go-sqlcmd>sqllocaldb info mssqllocaldb
    Name:               MSSQLLocalDB
    Version:            15.0.4382.1
    Shared name:
    Owner:              redacted
    Auto-create:        Yes
    State:              Running
    Last start time:    12/31/2024 10:24:23 AM
    Instance pipe name: np:\\.\pipe\LOCALDB#6894F7B1\tsql\query
    
    (built from cmd\modern folder)
    10:25:10.12 e:\git\go-sqlcmd\cmd\modern>modern -S np:\\.\pipe\LOCALDB#6894F7B1\tsql\query
    1> select @@servername
    2> go
    
    --------------------------------------------------------------------------------------------------------------------------------
    redacted\LOCALDB#6894F7B1
    
    (1 row affected)
    1>
    

    It's a poor substitute but worth a try until we have time to address it.

    yes with name pipe it's work, but it remains a dynamic path that we do not know beforehand to use it in installation scripts, for example.

    for now, the bug still persists, I even tried with the pre-release 1.19 and it’s the same issue.

  12. yooakim commented on Sep 24, 2025

    @yooakim

    Stuart Padley (@stuartpa) You probably need to add the -E to make the connection work, I just verified and this works fine for me:

    sqlcmd -S "np:\\.\pipe\LOCALDB#179C950B\tsql\query" -d databasename -E -Q 'SELECT * FROM Catalogs;'
    

    The issue is, as already mentioned above by David Shiflet (@shueybubbles) that the issues is the Go implementation does not find the pipe name from the name (LocalDb)\MSSQLLocalDb - this is a pitty because it makes much messier than they should be.

    Most tools can connect to (LocalDb)\MSSQLLocalDb but not the Go implementation of sqlcmd.

  13. richshadman commented on Aug 4, 2026

    @richshadman

    Any update on this? we are moving towards Entra ID authorization and the odbc version does NOT support features like workload identity, which means this version is our defacto version moving forward. We use localdb for unit tests with sqlcmd and this impacts us.

    EDIT : we have updated our tests to ensure using named pipe format which works however full support for instance name would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions