# Microsoft SQL Server

## **Create a Login and a User**

To set up access in SQL Server, one would create a login at the server level and then a user at the database level linked to that login. Below is an equivalent SQL Server script:

```sql
-- Replace placeholder values (YourDatabaseName, YourSchemaName, and <something secret>) 
-- with your actual values.

-- Create server-level login
CREATE LOGIN dot_login WITH PASSWORD = '<something secret>';

-- Use the desired database
USE YourDatabaseName;

-- Create database-level user linked to the server login
CREATE USER dot_user FOR LOGIN dot_login;

-- Add user to a role (for demonstration purposes, using db_datareader which gives read-only access)
ALTER ROLE db_datareader ADD MEMBER dot_user;

```

## **Grants Read Access to Data**

In SQL Server, the **`db_datareader`** role grants read-only access to all current and future tables in the database. If you've added the user to this role, you don't need to do schema-specific grants. However, if you wish to grant read access only on specific schemas:

```sql
-- Grant select on all current tables in a schema
GRANT SELECT ON SCHEMA::YourSchemaName TO dot_user;

-- Note: SQL Server does not support the concept of default privileges.
-- Any new tables or views would need permissions assigned explicitly.

```

## **Allow Dot IPs**

If you are using SQL Server's firewall features or another firewall mechanism to control access, ensure that you whitelist the following IPs to allow Dot to access your SQL Server:

* 3.229.110.216
* 3.122.135.165


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.getdot.ai/integrations/databases/microsoft-sql-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
