Is it safe to connect an AI assistant to SQL Server?

    Last updated · DB24 Team

    It can be, when the assistant can only read, reaches only what the question needs, and every call it makes is logged. The risk sits in the access you give it. A login with write permissions lets generated statements change data, rows the assistant reads are passed to the language model, and broad permissions reach far more than one question needs. Keep it read-only with a dedicated login and the least permission possible, expose views instead of tables, or use an MCP server that answers from monitoring data and never connects to your SQL Server instances.

    Key takeaways

    • Give the assistant its own login and the least permission it needs. Microsoft calls it "a good principle to always grant the least permission possible" (Microsoft).
    • Read-only is a permission setting in SQL Server. db_datareader can "read all data from all user tables and views"; db_denydatawriter "can't add, modify, or delete any data in the user tables" (database-level roles).
    • What the assistant reads goes to the language model. Choose the client and model with that in mind, and limit what the assistant can read.
    • Before you connect any MCP server, require read-only tools, a choice of which tools and SQL Server instances it reaches, keys with an end date, and a log of every call. The MCP specification says tools "represent arbitrary code execution and must be treated with appropriate caution" (MCP specification).

    What are the risks of giving an AI assistant access to SQL Server?

    Each risk comes from the access the assistant is given, so each can be limited with a permission or a setting.

    Risks when an AI assistant connects to SQL Server, and how to limit each
    RiskWhat can happenHow to limit it
    Write permissionsA generated statement changes or deletes data. Members of db_datawriter "can add, delete, or change data in all user tables"A login that can only read; add it to db_denydatawriter
    Permissions that are too broadThe assistant reads more than the question needs. Members of sysadmin "can perform any activity in the server"SELECT on one schema or a set of views; never sysadmin or db_owner
    Data passed to the modelTool results go back to the language model as part of the conversation, so rows read from a table leave SQL Server with themViews without sensitive columns, or answers from metadata instead of rows
    Generated SQLMicrosoft: "Models aren't deterministic, and complex queries are the most likely to produce subtle errors"Fixed tools with known queries; a person checks before acting on the answer
    Tool descriptions you cannot verifyDescriptions of tool behaviour "should be considered untrusted, unless obtained from a trusted server" (MCP specification)MCP servers from a source you trust, with each tool checked before it is allowed
    No recordNobody can say afterwards what the assistant asked or sawA log of every call with who, which tool and which arguments

    How do you keep an AI assistant read-only on SQL Server?

    Four ways, from the most direct to the most separated:

    • A dedicated read-only login: create a login only for the assistant and map it to a user in the databases it needs. Grant SELECT on the schema it should read, or add it to db_datareader if it needs every table. Microsoft: "Grant permissions to roles whenever possible" (permissions). Add the user to db_denydatawriter as well. Because "any permission denial overrides all grants", it stays read-only if a write permission is granted later. The exception is sysadmin, which "doesn't respect DENY" (security best practices).
    • Views instead of tables: put the columns the assistant may see in views in their own schema, and grant SELECT on that schema only. Microsoft: "Views can be used as security mechanisms by letting users access data through the view, without granting users permissions to directly access the underlying tables of the query" (views).
    • Server state for questions about the server: if the assistant answers questions about performance and configuration, SQL Server 2022 and later have fixed server roles "designed specifically with the Principle of Least Privilege in mind". ##MS_ServerPerformanceStateReader## reads the performance views covered by VIEW SERVER PERFORMANCE STATE, and ##MS_DefinitionReader## reads the catalog views covered by VIEW ANY DEFINITION (server-level roles).
    • An MCP server that answers from monitoring data: when the questions are about the estate (backups, versions, jobs, performance, disk space), the assistant needs no login on the SQL Server instances. An MCP server that reads what a monitoring tool has already collected answers them without connecting to SQL Server. The difference is explained in Is there an MCP server for SQL Server monitoring?

    What should you require before connecting an AI assistant?

    Ask for these whichever MCP server or login you use:

    1. Read-only tools, enforced by the server or the login. The MCP specification treats tool descriptions as untrusted unless the server is trusted, so an instruction to the model is not a control.
    2. A choice of which tools are switched on, and which SQL Server instances each key or login can reach.
    3. Keys that expire and can be revoked, one per use, so access can be withdrawn without touching anything else.
    4. A log of every call: which key, which client, which tool and which arguments. The specification says clients should "Log tool usage for audit purposes" (tools).
    5. A person in the loop. The specification: "there SHOULD always be a human in the loop with the ability to deny tool invocations".
    6. A client and a model your organisation has approved, since the questions and the answers pass through them.

    These are the same controls an auditor asks about for any other account. What to record for logins and permissions is in SQL Server security auditing, and the evidence a supervisor may ask for under NIS2 is in NIS2 and SQL Server.

    Want to see what an assistant can answer about your estate?

    In 30 minutes we show the DB24 MCP Server on a demo environment with sample data: which tools an administrator can switch on, how API keys are scoped, and what the request log records. No sales presentation.

    How DB24 helps

    DB24 2026.4 includes the DB24 MCP Server, so an AI assistant can answer questions about your SQL Server estate without a login on any SQL Server instance (release notes 2026.4):

    • Separate from your SQL Server instances: the MCP server is a separate Windows service installed by the DB24 installer. It exposes read-only tools only, never connects to your SQL Server instances, and answers from the DB24 Datastore, which collects data from every SQL Server that DB24 manages (overview).
    • You choose the tools: one switch per tool under Settings > MCP in the Portal, for administrators only. The tools cover SQL Server instances, databases, backups, performance, security, alerts, change tracking, availability groups, storage, patch status, SQL Agent jobs and AiQ. Tools that expose logins and database users are off by default.
    • You choose the SQL Server instances: include or exclude them one by one or by tag, and decide whether new SQL Server instances are visible by default.
    • Keys with an end date: API keys are scoped to tools and SQL Server instances, must have an expiry date, are shown once and stored hashed, and can be revoked at any time.
    • Every call logged: the request log records every tool call with the key, client, tool and arguments, and keeps it for 60 days.
    • Your choice of assistant: any MCP-capable assistant, such as Claude, Claude Desktop or VS Code Copilot. The model can be a cloud service or run on your own servers (DB24 MCP).

    DB24 collects only metadata and performance data, never the contents of your databases.

    DB24 is priced per SQL Server instance. Contact us for a quote.

    Which tools to switch on, who gets a key and which assistant your organisation uses stay your decisions; DB24 applies them and keeps the log. More in What's new in DB24 2026.4.

    Existing DB24 customers can book a walkthrough on their own environment. If you do not run DB24 yet, we show it on a demo environment. Contact us.

    When is DB24 a good fit?

    • You run many SQL Server instances and want questions about backups, versions, jobs and performance answered across all of them.
    • Nobody owns SQL Server full time, and questions wait for the one person who knows where to look (SQL Server without a DBA).
    • You need to document access under NIS2, and want a record of every question an assistant has asked.
    • You want more people on the team to get answers without giving them logins on the SQL Server instances.
    • You want the assistant kept away from the data inside your databases.

    Something else fits better when the assistant has to work with the data in your tables, such as orders or customer records. Then you need an MCP server that connects to the database, for example Microsoft's SQL MCP Server in Data API builder, where you choose which tables, views and stored procedures it exposes and which roles may read, create, update or delete (Microsoft). Apply the requirements above to it.

    Frequently asked questions

    Can an AI assistant change data in SQL Server?

    Only if its login has permission to. A user in db_datareader and db_denydatawriter can read but cannot add, change or delete data in user tables. A member of sysadmin can do anything and DENY does not apply to it, so an assistant should never use a sysadmin login.

    Is db_datareader enough to keep an assistant read-only?

    On its own it only grants reading, but on every user table and view in the database. Permissions add up, so check the login's other roles and permissions too. When the assistant needs part of the data, grant SELECT on a schema of views instead.

    Does the language model see my data?

    It sees what the assistant reads. Tool results go back to the model, so rows read from a table are sent to the model you use. With an MCP server that answers from monitoring data, the model sees facts about your databases, such as backup times and versions, and no rows from your tables.

    What is an MCP server?

    A server that gives AI assistants tools and data through the Model Context Protocol, "an open protocol that enables seamless integration between LLM applications and external data sources and tools" (MCP specification). More in Is there an MCP server for SQL Server monitoring?

    Does the DB24 MCP Server need a login on our SQL Server instances?

    No. It never connects to your SQL Server instances. It answers from the DB24 Datastore, which the DB24 Runtime on each managed SQL Server reports to.

    How much does DB24 cost?

    DB24 is priced per SQL Server instance. Contact us for a quote.

    Want to see what an assistant can answer about your estate?

    In 30 minutes we show the DB24 MCP Server on a demo environment with sample data: which tools an administrator can switch on, how API keys are scoped, and what the request log records. No sales presentation.

    Sources

    1. Microsoft Learn, Get started with Database Engine permissions
    2. Microsoft Learn, Database-level roles
    3. Microsoft Learn, Server-level roles
    4. Microsoft Learn, SQL Server security best practices
    5. Microsoft Learn, Views
    6. Microsoft Learn, SQL MCP Server overview
    7. Model Context Protocol, Specification
    8. Model Context Protocol, Tools
    9. DB24 Docs, Version 2026.4
    10. DB24 Docs, Overview
    11. DB24 MCP
    12. What's new in DB24 2026.4