How to Configure GitHub Copilot SQL Server Credentials
You set up github copilot sql server credentials by creating a read-only database user. Then you pass those login details to the local tool that runs queries. Many teams start by reusing an existing app login or an admin account. This shortcut gives the coding assistant far too much power over live tables. If the assistant runs a bad query, it can change or delete records. A safer plan starts with a locked-down user inside the database engine. How to set up github copilot sql server credential
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You set up github copilot sql server credentials by creating a read-only database user. Then you pass those login details to the local tool that runs queries. Many teams start by reusing an existing app login or an admin account. This shortcut gives the coding assistant far too much power over live tables. If the assistant runs a bad query, it can change or delete records. A safer plan starts with a locked-down user inside the database engine.
How to set up github copilot sql server credentials
SQL Server separates server logins from database users. A database user is the identity of a login inside one specific database. When a person needs to reach many databases, admins create a login in master. Then they map that login to a user inside each target database. If the assistant only needs one database, you can use a contained user. A contained database user has its own password and does not need master. Before using one, an admin must turn on contained databases on the server. They must also enable containment on the target database itself.
After you create the user, you must assign it a role. SQL Server includes fixed database roles with permissions that you cannot change. Every role in the database includes the basic right to connect. For an AI assistant, teams pick the fixed role built for reading data. Members of this read role can read all data from all user tables. They can also read data from all views inside that database. You can also add a deny write role for extra safety. Members of the deny write role cannot add, change, or delete any data. Avoid the owner role, because it allows full maintenance and can drop databases.
Once the database user is ready, the coding assistant needs a way to connect. Coding assistants reach databases through local command tools or external tool servers. Developers place the database user and password into a local setting file. They might also store the secret in a local system variable on their machine. When you ask a question in your editor, the assistant reads that secret. It opens a session to SQL Server and sends the query for you.
What native database roles solve and what they miss
Using a read-only database user solves the problem of accidental data changes. Even if the assistant writes a delete statement, the database blocks the action. The fixed read role stops the user from dropping tables or changing rows. This setup is a strong first step for any team using AI tools.
Still, native database roles leave big gaps in day-to-day work. First, the fixed read role lets the user read every single user table. It can read billing tables, user accounts, and private system records alike. When the assistant runs a select query, the database returns raw data values. Sensitive fields like emails, phone numbers, card numbers, and national IDs come back whole. Those raw values flow straight into the assistant context and leave the database.
Ephemeral Credentials + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Second, static credentials sit on developer laptops in plain text files. Anyone or any local script on that machine can read the password. If a developer shares a project folder, the secret can leak by mistake. Also, every query from that machine looks the same inside the database logs. Admins see the shared read-only user name, not the person who ran it. Finally, a database role only checks who logs in at the start. It does not inspect individual statements in flight or pause risky reads for approval.
Why statement-level controls matter for AI assistants
AI coding tools work fast and generate many queries during a single task. A static role cannot tell a safe schema check from a broad data dump. Teams need a way to inspect each query before the database runs it. They also need a way to rewrite matched sensitive fields in query results. When emails or card numbers get masked in flight, raw values stay protected. Removing static passwords from local files also stops credential leaks on developer machines.
Add runtime guardrails beside SQL Server
Role grants and network rules are needed setup for SQL Server. Still, an allowed user or agent tool can send a bad delete or read raw customer fields over a valid session. In practice, hoop.dev sits inline in the TDS protocol beside the database as a sidecar for your SQL Server. For every query an agent or human runs in production, hoop.dev decides whether to pass, mask, block, or escalate it for review.
With hoop.dev SQL Server controls, rules refuse banned statements before they run, hold risky queries for human review, and mask matched sensitive values in supported result columns in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for HIPAA, PCI DSS, SOX, and GDPR audits. See the source on GitHub.
Frequently asked questions
Should I give an AI coding assistant the database owner role?
No, you should never assign the database owner role to an assistant. That role can run all maintenance tasks and can even drop the database. Always use a read-only role so the tool cannot change or delete data.
When should I use a contained database user in SQL Server?
Use a contained user when the tool only needs one or a few databases. It keeps the user and password inside the target database instead of master. Remember that an admin must enable containment on the server and database first.
Does a read-only role hide emails or card numbers from query results?
No, the fixed read role lets the user read all data in user tables. It returns raw emails, phone numbers, card numbers, and national IDs in results. You need field masking in flight to rewrite those values before they return.
Related guides
In this post