> ## Documentation Index
> Fetch the complete documentation index at: https://basedash.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# SQL Server

> Connect your Microsoft SQL Server database to Basedash

Connect your Microsoft SQL Server database to Basedash to visualize and analyze your application data. Basedash connects directly and queries your data in place.

This also works for managed SQL Server offerings such as Azure SQL Database, Azure SQL Managed Instance, Amazon RDS for SQL Server, and Cloud SQL for SQL Server.

## Connection URI (recommended)

The easiest way to connect is by using a connection string (URI). In Basedash, press <kbd>Command</kbd> + <kbd>K</kbd> and paste your connection string to start the connection flow immediately.

Example:

```
sqlserver://[USERNAME]:[PASSWORD]@[HOST]:1433?database=[DATABASE]
```

## Manual connection details

If you prefer to enter credentials manually, use the following details:

1. From your Basedash dashboard, click "Add Data Source"
2. Select "SQL Server" as your database type
3. Enter your connection details:
   * Host (e.g., `your-server.database.windows.net`)
   * Port (default: 1433)
   * Database name
   * Username
   * Password
   * SSL (if required)
4. Click "Test Connection" to verify
5. Save your connection

### SSH tunnel

For enhanced security when your database is in a private network:

1. Follow the manual connection steps above
2. Enable "Connect via SSH" option
3. Add our IP (`24.199.77.73`) to your allowlist
4. Provide SSH connection details:
   * SSH host
   * SSH username
   * Set "Authentication method" to "Private key" (recommended) and upload your SSH private key. Password authentication is also supported.
5. Test and save the connection

## Required permissions

Create a dedicated login for Basedash and grant read access to the schemas you want to analyze:

```sql theme={"dark"}
CREATE LOGIN basedash WITH PASSWORD = '<strong-password>';
USE [your_database];
CREATE USER basedash FOR LOGIN basedash;
ALTER ROLE db_datareader ADD MEMBER basedash;
```

## Best practices

* Use a read-only login for Basedash
* Enable SSL for secure connections
* Consider using an SSH tunnel for databases in private networks
* Regularly rotate database credentials

## Troubleshooting

* Verify firewall rules allow connections from the Basedash IP (`24.199.77.73`)
* For Azure SQL, add the Basedash IP to the server's firewall rules
* Confirm the login has access to the database you entered
* Check that SQL Server authentication (not only Windows authentication) is enabled

## Next steps: Add custom context

You can add custom context to help the AI better understand your data structure and business logic. Consider adding context at the database or schema level if you notice the AI struggling to locate or understand specific data.

### When to add context

* **Unclear naming conventions**: If table or column names don't clearly indicate their purpose
* **Business-specific terminology**: When your data uses internal abbreviations or custom terms
* **Legacy schemas**: When the AI needs help understanding which tables are current

For detailed guidance, see our [custom context documentation](/docs/features/custom-context).
