Skip to main content
ClaudeChatGPT

Microsoft SQL Server

Use this guide to connect Microsoft SQL Server to Wren AI and continue through connection, table selection, and relationship setup.

Plan support

Included in all plans

IP Whitelist for Wren AI Cloud

Wren AI needs to access your Microsoft SQL Server database via the outbound IP address of Wren AI Cloud. Please add the IP address of the Wren AI service to the firewall of your Microsoft SQL Server database.

Scroll to the bottom of the data source connection page to find the IP address.

Required Permissions

Wren AI connects to SQL Server as a regular database user and only issues read-only queries — SELECT against your tables/views and system catalog views. It will never INSERT, UPDATE, DELETE, or run DDL (CREATE, ALTER, DROP, TRUNCATE). Read-only grants are sufficient — and recommended — for a secure connection.

Do not connect as an administrator

Avoid using sa or any broadly privileged account as the connecting account. It violates least-privilege principles and may expose more databases than you intended. Use a dedicated read-only user whenever possible.

Privileges checklist

The SQL Server login used by Wren AI needs the following on your target database:

CategoryPrivilegeNotes
LoginA valid SQL Server login and database userRequired to connect.
Business dataSELECT on the tables/views you want Wren AI to readGrant per schema, for example GRANT SELECT ON SCHEMA::dbo TO wren_ai;, or add the user to the db_datareader role to read all tables in the database.
Metadata discoveryRead access to INFORMATION_SCHEMA and sys catalog viewsSQL Server only shows metadata for objects the user has permission on, so SELECT grants above also drive what Wren AI can discover.

Minimum account setup

Create a dedicated read-only user:

-- On the server
CREATE LOGIN wren_ai WITH PASSWORD = 'YourStrongPassword!';

-- In the target database
USE your_database;
CREATE USER wren_ai FOR LOGIN wren_ai;

-- Option A: read access to specific schemas
GRANT SELECT ON SCHEMA::dbo TO wren_ai;

-- Option B: read access to the whole database
ALTER ROLE db_datareader ADD MEMBER wren_ai;

Verify the account

Connect as the new user and confirm it can see the tables Wren AI will discover:

SELECT TABLE_SCHEMA, TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE IN ('BASE TABLE', 'VIEW');

SELECT TOP 5 * FROM dbo.your_table;

To add a Microsoft SQL Server connection, click on the SQL Server option in the Connect a data source section. connect

Connect

Fill in the connection settings: sqlserver_1

Display name

The display name for the database in the Wren AI interface.

Host

Your SQL Server database's IP address or domain name.

Port

Your SQL Server database port.

Username

The database username for the account that you want to use to connect to your SQL Server database.

Password

The password for the username that you use to connect to the database.

Database name

The name of the database you want to connect to.

Click Next to start the connection and go to the next step.

sqlserver_2

Select Tables

All tables of your connected SQL Server dataset will be listed in this step. Select which tables you want to use in Wren AI. Each selected table will be created as a data model. See the Modeling documentation to learn more about data models. select_table

Define relationships

Define the relationships among selected tables in this step. If you have defined primary keys and foreign keys in your SQL Server dataset, we will list suggested relationships based on that information. If not, you can also add relationships by clicking the Add relationships button on the table blocks. define_relationship_1

Define the following properties in a relationship:

  • From: Select the left side table and column of this relationship.
  • To: Select the right side table and column of this relationship.
  • Relationship Type: Select the type of relationship. define_relationship_2

Find more information about relationships in Modeling - Working with Relationships.

You can also skip this step and finish the connection.

Tested versions

Wren AI connects to SQL Server over the standard TDS protocol, and recent SQL Server versions are expected to work. If you hit a version-specific issue, please contact us.