# Microsoft SQL Server Microsoft SQL Server Permissions

Source: https://userguide.qualytics.io/source-datastore/datastore/jdbc/microsoft-sql-server/permissions/

> **Info: Permissions in your Microsoft SQL Server**
>
> The permissions on this page are granted in your own Microsoft SQL Server, to the account Qualytics connects with, by whoever administers Microsoft SQL Server at your company. They let Qualytics connect the datastore and read your data, and write to it when it is an enrichment datastore. They are not Qualytics roles or team permissions. To know which Qualytics user role (**Admin**, **Manager**, or **Member**) and team permission you need to connect the datastore in Qualytics, see [Source Datastore Permissions](https://userguide.qualytics.io/source-datastore/datastore/deep-dive/permissions/).

Qualytics connects to Microsoft SQL Server through the **Microsoft JDBC Driver for SQL Server**. It queries `sys.schemas` joined with `sys.database_principals` to list the schemas the login can see, rather than the driver's generic metadata call, which can omit `dbo` depending on the driver version and the permissions in place. Tables, columns, and primary keys come from the standard JDBC metadata APIs.

## Minimum SQL Server Permissions (Source Datastore)

| Permission | Purpose |
| --- | --- |
| `CONNECT` | Allow the user to connect to the database |
| `SELECT ON SCHEMA::<schema_name>` | Read data from all tables and views for profiling and scanning |
| `VIEW DEFINITION ON SCHEMA::<schema_name>` | Read object definitions for metadata discovery |

> **Note: Schemas owned by a user or role you created**
>
> Schema discovery reads the schema list together with each schema's owner, and the permissions
> above are enough for the common case: a login always sees the schemas owned by `dbo`, by another
> built-in user, or by a built-in database role. A schema owned by a user or a role that you
> created yourself is listed only when the connecting login can also see that owner.
>
> So if a schema is missing from the **Schema** list, check who owns it. What opens it up depends
> on the kind of owner.
>
> **When a user you created owns it**, one permission on that user is enough. Prefer this over
> `ALTER ANY USER`, which also works but lets the login change any user in the database.
>
> ```sql
> GRANT VIEW DEFINITION ON USER::<owner_name> TO qualytics_read;
> ```
>
> **When a role you created owns it**, a permission on the role is not enough: SQL Server shows
> such a role only to its members and to logins holding `ALTER ANY ROLE`. Add the login to the
> role instead.
>
> ```sql
> ALTER ROLE <role_name> ADD MEMBER qualytics_read;
> ```
>
> Membership carries whatever the role itself grants, so check that first. If it hands over more
> access than you want, transfer the schema to `dbo` instead, keeping in mind that transferring a
> schema drops the permissions on any object inside it that has no explicit owner.

## Additional Permissions for an Enrichment Datastore

When SQL Server is used as an enrichment datastore, the following additional permissions are required so Qualytics can write its outputs, which are named from the linked source's prefix (for example `_tpch_failed_checks`):

| Permission | Purpose |
| --- | --- |
| `CREATE TABLE` | Create enrichment outputs |
| `INSERT ON SCHEMA::<schema_name>` | Write anomaly records, scan results, and check metrics |
| `UPDATE ON SCHEMA::<schema_name>` | Update enrichment records during rescans |
| `DELETE ON SCHEMA::<schema_name>` | Replace records when a run overwrites an output |
| `ALTER ON SCHEMA::<schema_name>` | Modify enrichment table schemas during version migrations |
| `DROP TABLE` | Replace an output when a run overwrites it (Overwrite remediation, Materialize, Export) or when a schema change requires recreating it. Unlinking never removes written data |

## Example: Source Datastore User (Read-Only)

Replace `<database_name>`, `<schema_name>`, and `<password>` with your actual values.

```sql
-- Create a login at the server level
CREATE LOGIN qualytics_read WITH PASSWORD = '<password>';

-- Switch to the target database
USE <database_name>;

-- Create a user mapped to the login
CREATE USER qualytics_read FOR LOGIN qualytics_read;

-- Grant connection and read-only access
GRANT CONNECT TO qualytics_read;
GRANT SELECT ON SCHEMA::<schema_name> TO qualytics_read;
GRANT VIEW DEFINITION ON SCHEMA::<schema_name> TO qualytics_read;
```

## Example: Enrichment Datastore User (Read-Write)

```sql
-- Create a login at the server level
CREATE LOGIN qualytics_readwrite WITH PASSWORD = '<password>';

-- Switch to the target database
USE <database_name>;

-- Create a user mapped to the login
CREATE USER qualytics_readwrite FOR LOGIN qualytics_readwrite;

-- Grant connection, read-write, and table management access
GRANT CONNECT TO qualytics_readwrite;
GRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::<schema_name> TO qualytics_readwrite;
GRANT CREATE TABLE TO qualytics_readwrite;
GRANT ALTER ON SCHEMA::<schema_name> TO qualytics_readwrite;
GRANT VIEW DEFINITION ON SCHEMA::<schema_name> TO qualytics_readwrite;
```

> **Note**
>
> If using **Service Principal** authentication, ensure the Service Principal has been added as an external user in the database with the same permissions listed above. Use the Client ID, Client Secret, and Tenant ID from your Microsoft Entra ID app registration.

> **Note**
>
> Schema discovery leaves out `INFORMATION_SCHEMA`, `sys`, and any schema whose name starts with `db_`, so you do not need to restrict access to those by hand. The `master`, `model`, `msdb`, and `tempdb` system databases are left out too, so they never appear in the **Database** list.

*Last updated: November 16, 2026.*
