sqlcmd
can’t always resolve (localdb)\MSSQLLocalDB
because LocalDB uses a dynamic pipe name. From your output:
np:\\.\pipe\LOCALDB#8DB1A806\tsql\query
Try connecting with the full pipe path:
sqlcmd -S "np:\\.\pipe\LOCALDB#8DB1A806\tsql\query" -E
If that works, the issue is usually:
Old sqlcmd
version – update to the latest SQL Server Command Line Utilities (2022).
Wrong executable in PATH – run where sqlcmd
to check.
SSMS resolves LocalDB automatically, but older sqlcmd often does not.