# Connect SQL Server (/docs/connect/sql-server)

Connect Dora to Microsoft SQL Server or Azure SQL Database with a SQL login.

Dora speaks TDS, the native SQL Server protocol, so it connects to SQL Server
2019 and newer, SQL Server in Docker, and Azure SQL Database. Support is at
**beta** level: browse every schema in a database, run T-SQL, edit rows inline,
and export tables.

## With host and credentials [#with-host-and-credentials]

1. In Dora press `Mod+Shift+N` and pick **SQL Server**.
2. Fill in the host, port (default `1433`), user, password, and database
   (default `master`).
3. **Test connection**, then **Save connection**.

Dora always encrypts the connection. Local and development servers usually
present a self-signed certificate; turn on **Trust server certificate** for
those. Leave it off for servers with a certificate your system trusts, such as
Azure SQL.

## With a connection string [#with-a-connection-string]

Paste any of these into the connection dialog. Dora converts ADO.NET and JDBC
strings to the URL form it stores:

```text
sqlserver://sa:<password>@localhost:1433/master?trustServerCertificate=true
Server=tcp:<server>.database.windows.net,1433;Initial Catalog=<db>;User ID=<user>;Password=<password>;
jdbc:sqlserver://localhost:1433;databaseName=master;user=sa;password=<password>;trustServerCertificate=true
```

URL options:

| Option                        | Effect                                                    |
| ----------------------------- | --------------------------------------------------------- |
| `trustServerCertificate=true` | Accept a self-signed or untrusted server certificate      |
| `encrypt=false`               | Encrypt only the login, not the session (not recommended) |

`*.database.windows.net` hosts are recognized as Azure SQL.

## Running T-SQL [#running-t-sql]

The SQL console understands `GO` batch separators the way SSMS and `sqlcmd` do:
each batch runs on its own, and `GO 5` repeats the batch five times. Within a
batch, plain statements run one by one. A batch that declares variables or uses
control flow (`DECLARE`, `IF`, `WHILE`, `BEGIN ... END`) runs as one unit so its
variables stay in scope.

Statements run on one session, so temporary tables and `USE <database>` carry
over to the next statement.

## Local SQL Server in Docker [#local-sql-server-in-docker]

```bash
docker run -e ACCEPT_EULA=Y -e MSSQL_SA_PASSWORD='Str0ng!Pass' -p 127.0.0.1:1433:1433 \
  -d mcr.microsoft.com/mssql/server:2022-latest
```

Then connect to `localhost`, user `sa`, with **Trust server certificate** on.

## Not supported yet [#not-supported-yet]

<Callout type='info'>
	Windows authentication and Microsoft Entra ID sign-in are not supported yet; use a SQL Server
	login. Live table monitoring, database dumps, soft delete, and the stored procedure browser are
	also not available for SQL Server in this beta.
</Callout>
