Skip to content

Instantly share code, notes, and snippets.

@KirovAir
Last active June 25, 2025 16:02
Show Gist options
  • Select an option

  • Save KirovAir/93c182d2d4b08687e61aba14cb1530a9 to your computer and use it in GitHub Desktop.

Select an option

Save KirovAir/93c182d2d4b08687e61aba14cb1530a9 to your computer and use it in GitHub Desktop.
Connect HeidiSQL to MSSQL LocalDB

Connect HeidiSQL to MSSQL LocalDB

This batch script starts the MSSQLLocalDB instance (if not already running), retrieves its named pipe connection string, updates the Windows Registry to point HeidiSQL to it, and finally launches HeidiSQL.

@echo off
REM Start LocalDB instance (if not already running)
sqllocaldb start MSSQLLocalDB

REM Get the named pipe connection string
FOR /f "tokens=2*delims=::" %%a IN ('sqllocaldb info MSSQLLocalDB') DO (
  IF "%%a"==" np" SET "pipename=%%b"
)

echo %pipename%

REM Write pipe name as host in registry for HeidiSQL connection
REG ADD "HKEY_CURRENT_USER\Software\HeidiSQL\Servers\Localdb" /v "Host" /t REG_SZ /d "%pipename%" /f
echo Registry updated successfully.

REM Launch HeidiSQL
start "" "C:\Program Files\HeidiSQL\heidisql.exe"

💡 Tip: Ensure you’ve already created a "Localdb" server configuration in HeidiSQL beforehand, so this registry update maps correctly.

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