M365 Show -  Microsoft 365 Digital Workplace Daily
M365 Show with Mirko Peters - Microsoft 365 Digital Workplace Daily
The Secret to Putting SQL Data in Copilot Studio
0:00
-21:00

The Secret to Putting SQL Data in Copilot Studio

Opening: The Copilot That Knows Nothing

Your Copilot is fluent, confident, and utterly clueless. It greets your employees like an expert, yet it’s blind to the existence of your customers, invoices, or inventory. You think it knows your business? It doesn’t. It knows Wikipedia.

Inside your network, SQL Server holds your company’s actual memories—the sales you’ve made, the people you’ve invoiced, the chaos of human data. But Copilot Studio sits outside that fortress, smiling through the glass, pretending it understands.

The irony is beautiful: a so‑called “intelligent assistant” that can’t see the data that built your business. The bridge it needs is the Power Platform Data Gateway—your secure tunnel through the firewall that lets Copilot observe SQL in real time without ever exposing it. By the end of this session, you’ll wire that bridge, query live tables, and even teach Copilot to write back. No magic—just architecture executed properly.

Section 1: Why Copilots Fail Without Context

A Copilot, disconnected from your structured data, is little more than a verbose fortune teller. It generates words that sound authoritative but are entirely divorced from operational truth. Ask it about this quarter’s customer churn, and it’ll estimate. Ask it who owed you money last month, and it’ll hallucinate confidence while inventing numbers. That’s what happens when large language models are forced to perform without grounding—they produce statistically likely nonsense.

Enterprises perpetuate this blindness by keeping their AI in the cloud but their data in the basement. Security teams erect beautiful firewalls, compliance officers forbid inbound connections, and the poor Copilot—stuck in its public sandbox—sifts through generic training data and calls it knowledge. It’s as if you hired a consultant who’s read every business book ever written but has never seen your balance sheet.

Inside your walls, SQL Server remains the spinal cord of real business function. Every order, every update, every miskeyed customer address pulses through it. It isn’t glamorous, but it’s reliable—the relational glue that binds your ERP, CRM, and those Excel spreadsheets labeled “final_v27.” Without access to that structured intelligence, an AI agent has the literacy of a genius child reading random encyclopedias. It knows language, not meaning.

The wall exists for good reason. Directly exposing SQL data to the cloud is corporate self‑harm. Firewalls, network zones, and authentication boundaries exist precisely because someone once tried “just opening a port” and spent the next quarter explaining the breach. Compliance frameworks require data residency, and auditors demand logs that show precisely who touched which record. So yes, the wall must stay.

Yet isolation isn’t the answer either. The ideal is hybrid parity—keeping on‑prem control while granting the cloud intelligent visibility. That balance transforms AI from a parlor trick into a dependable analyst. Picture a system where your Copilot reads customer orders the instant they’re updated, where it summarizes invoices without exporting CSVs, and where every query is authenticated, encrypted, and auditable. That’s hybrid done correctly.

Understanding this split—the genius trapped outside and the data locked inside—is the first step toward appreciating the architectural sleight of hand that solves it. Before we talk about data, think in biology: the body operates because the spinal cord connects brain to muscle without exposing nerves to daylight. In technology, the Power Platform Data Gateway does precisely that. It’s not just a tunnel; it’s a disciplined neural bridge that keeps both hemispheres synchronized and secure. Once you understand that, everything about hybrid AI begins to click.

Section 2: Enter the Data Gateway — The Spine of Hybrid AI

Let’s start with a correction of language. People call the Power Platform Data Gateway “middleware.” That word is an insult. Middleware is what you use when two systems refuse to cooperate. The gateway isn’t a translator—it’s a spinal column. It links the cloud’s analytical brain with the reflex‑driven body of your on‑prem SQL Server. Those two hemispheres must communicate constantly, but never recklessly. The Data Gateway handles that conversation with surgical precision.

Here’s how it thinks. Nothing from the cloud ever knocks on your firewall. The gateway maintains sovereignty by initiating every conversation outward. Picture it like an employee who only makes phone calls; they never accept incoming ones. The cloud sends no invitation—your gateway dials the number, encrypts the session, verifies the credentials, and keeps the channel alive just long enough for safe command and response. From a security auditor’s perspective, that one architectural decision—outbound only—is the difference between compliance and chaos.

Now, installing it is almost disappointingly simple. You download the On‑Premises Data Gateway client, sign in with your organization’s Power Platform account, and register it under a unique gateway cluster name. Behind that modest interface lives serious engineering: connection strings sealed in the Windows credential store, symmetric keys for data encryption, and a lightweight Windows service dedicated to maintaining secure communication with Azure. The moment registration completes, your local server quietly joins the roster of trusted hybrid nodes recognized by the Power Platform.

Gateway clusters are the unsung heroes of enterprise resilience. You can deploy more than one instance on separate machines, each functioning as a backup route. Should one node stop responding—maybe a maintenance reboot or a hardware hiccup—the others continue routing traffic. Power Platform services automatically balance connections between available members. The result: high availability without ever exposing an open port. Microsoft designed it so reliability never trades places with recklessness.

And here’s the bonus most overlook: one gateway serves them all. The same installation that enables your Copilot to query local SQL also powers reports in Power BI, apps in Power Apps, and flows in Power Automate. In other words, every hybrid connection in the Power Platform ecosystem shares that identical spinal path. Each signal runs up and down the same nerve, and none of them bypass security policy. That shared backbone eliminates redundant connectors and network clutter—one disciplined bridge instead of four chaotic tunnels.

Let’s pre‑empt the paranoia that flares in every security review. No, the gateway does not upload your database. It doesn’t clone, mirror, or replicate anything. All it does is execute queries on your behalf and return the results—just as if a well‑trained employee ran a stored procedure and copied the outcome into a secure message. The session keys roll frequently, the payloads are encrypted end‑to‑end using TLS, and authentication goes through Azure Active Directory or the credentials you explicitly supply. There is no ghost copy, no hidden cache, no covert synchronization hiding under your desk.

For regulatory environments that live in audit logs, the gateway also generates telemetry. Every call, every result set, every authentication handshake can be tracked through Power Platform monitoring tools. That means you can prove to compliance—line by line—that data never left your trusted boundary unencrypted. The effect is paradoxical: opening the wall actually strengthens your evidence of control. Auditors love diagrams with gateways because suddenly the arrows in the network map point the correct way—outbound.

So to recap in biological terms: SQL Server is the muscle. Copilot Studio is the frontal cortex. The Data Gateway is the myelinated nerve fiber connecting the two—a highway of electrical activity wrapped in layers of encryption instead of tissue. Without it, the cloud brain sends commands that never reach the limbs. With it, queries, updates, and context flow symmetrically, both directions, without violating the skin of your perimeter.

Once that spine exists, we can attach the brain. Copilot Studio will soon learn to read your SQL tables as Knowledge Sources, constructing natural‑language questions that translate into precise T‑SQL commands. The gateway stands guard, translating intent into execution and returning verified results. What happens next—when the Copilot finally understands the contents of those tables in real time—is where the promise of hybrid AI stops being a buzzword and becomes a functioning nervous system. And yes, that’s our next step.

Section 3: Teaching Copilot to Read SQL — Adding Knowledge Sources

A Copilot without data is like an intern with enthusiasm and no memory. It smiles, nods, and answers confidently while secretly improvising. The first lesson in hybrid AI literacy is giving that intern access to the company’s archives—carefully, securely, and on your terms. That’s where Knowledge Sources in Copilot Studio come in. What you’re about to build isn’t a simple connection string; it’s cognition.

We begin with a blank agent in Copilot Studio. It’s empty—no knowledge, no tools, just linguistic talent waiting for context. The moment you click Add Knowledge, you shift from wordplay to data access. Choose Azure SQL as the source, and here the Data Gateway performs its first act of diplomacy. Because you already registered it, your local SQL instance quietly appears in the connection list. It’s that same gateway sitting inside your network, initiating outbound trust to Power Platform. You select it, authenticate, and point to the database holding your operational truth.

Authentication matters more than most realize. SQL Authentication uses dedicated database credentials—simple but local. Windows Authentication leverages existing Active Directory trust, perfect when your gateway machine already belongs to the domain. Then there’s the Azure Hybrid approach, where Azure AD acts as broker between cloud identity and local permissions. Each option satisfies different combinations of corporate paranoia and practical need. The point is that Copilot never sees the password directly; the gateway handles credential storage through encrypted reference, as if it were the company’s sealed envelope policy.

Once authenticated, Copilot Studio politely asks what you’d like it to know. Each table or view you select defines a boundary of knowledge. Choose carefully. Feed it messy schema, and you’ll train confusion; feed it normalized, well‑named views, and it will respond like a seasoned analyst. Think of schema design as diction—clear column names become vocabulary Copilot can use, while cryptic abbreviations turn sentences incoherent. The model doesn’t “understand” joins, it infers relationships from the structure you expose. That’s why many architects create read‑optimized views—condensed, precise representations of the truth, pre‑joined and scrubbed of sensitive columns.

After linking tables, Copilot Studio indexes their metadata through the gateway. It doesn’t duplicate your data; instead, it prepares schemas for dynamic querying. When you ask a question—say, “What’s Greenfield Corp’s recent order total?”—Copilot generates an internal SQL statement referencing those views. The gateway executes it locally, pulls back results, and sends a sanitized JSON payload to the model. The model then reformats that output into natural speech. To you, it looks like language magic. To the network administrator, it’s a single outbound call wrapped in TLS, logged, and closed.

Context persistence is where things feel eerily human. Ask about Greenfield Corp’s latest order, then immediately follow up with “What items were included?” Copilot doesn’t lose track of the subject, because conversation history and query context ride the same secure path. It remembers the customer referenced, constructs a second SQL query filtered by that ID, and delivers the itemized list—still without pre‑storing anything. Essentially, Copilot behaves like an attentive analyst who keeps the prior spreadsheet open while answering the next question.

Because every query travels live through the gateway, responses reflect the current state of SQL at the exact moment you ask. Modify a record in SQL Management Studio and re‑ask; the answer updates instantly. That’s not caching—it’s genuine real‑time data retrieval. This immediacy closes the classical lag between analytics and operations. Your Copilot stops being a storyteller about old data and becomes a reporter for the present tense.

Common mistakes? Over‑permissive access tops the list. Always restrict the connection to the few tables Copilot actually needs. And avoid giant, unfiltered result sets; language models aren’t designed to summarize millions of rows at once. Instead, scope the knowledge through concise, relevant views. Another pitfall is forgetting data types: Copilot interprets the schema literally. If you store numeric identifiers as strings, expect confusion. The more disciplined your database design, the more articulate your Copilot becomes.

So what have we accomplished? We’ve given the intern eyesight. Copilot can now read live company data with perfect recall and zero exfiltration risk. It answers customer queries by translating natural language into SQL, executing in milliseconds through your gateway. And while that’s impressive—an AI that reads your ledger like a novel—the real transformation happens when it learns to act. Reading data makes it informative; writing data makes it valuable. In the next stage, we give it hands. With SQL actions and controlled write‑backs, that eager intern upgrades to a trusted employee capable of updating reality, not merely describing it.

Section 4: Giving Copilot Hands — SQL Actions and Write‑Backs

Up to this point, your Copilot has been the perfect data analyst—curious, articulate, but fundamentally harmless. It observes your SQL Server like a museum visitor behind rope barriers. Now we remove the glass. The time has come for Copilot to act on the world it understands, to insert, update, and maintain records through SQL rather than merely describe them. This is the moment Copilot graduates from librarian to employee.

In Copilot Studio, that transformation begins in the Tools section—sometimes labeled Actions. Here you define what the AI is allowed to do. Each action is a contract between human administrators and machine intention: you expose certain functions, describe them clearly, and let the model decide when they’re appropriate. Conceptually, these are APIs with etiquette. Without them, Copilot speaks; with them, Copilot performs.

Start by adding a new action and choosing the SQL Connector. The options mimic the verbs of database life—insert, update, delete, execute stored procedure. Let’s select Insert Row because creation is the purest form of proof. The interface prompts you to pick a connection, the same one we configured earlier through the Data Gateway. That continuity matters. It means your write operations travel along the same encrypted nerve as your queries—no extra tunnel, no unmonitored path. Authentication context is preserved, and governance remains intact.

Next, you identify where this action should operate. Choose your database, then your table—perhaps Customers. The moment you select it, Copilot Studio introspects the schema and lists the columns as input parameters. These become the fields Copilot must supply before executing the SQL command. Think of each parameter as a missing puzzle piece the language model has to find through conversation.

The art lies in labeling. Don’t leave parameter names as cryptic identifiers like cust_ID or ph_num. Rename them to natural prompts—“Customer ID,” “Phone Number,” “Email Address.” In the model’s world, clarity is destiny. You can also provide concise descriptions for each field: “Unique numeric ID for the customer,” “Primary contact email,” and so forth. These hints guide Copilot’s slot‑filling logic when it lacks information. For example, if a user says, “Add a new client named Dubard 365,” the model sees it has a name but no phone or address. It asks politely, “What’s their phone number and business address?” That follow‑up isn’t scripted; it’s inference born from your parameter metadata.

Once Copilot gathers all required inputs, the gateway executes the SQL command silently, just as before—outbound, encrypted, logged. Within seconds, the new record materializes inside SQL Server. The experience to the user feels magical: one conversational request creates tangible data in an on‑prem system without any browser plugin or direct database exposure. The firewall remains unsullied; the network admin remains calm.

Validation is critical here. The connector respects SQL constraints—primary keys, data types, and triggers—but it’s wise to implement additional sanity checks. You can include conditional flows in Copilot Studio to confirm before committing, like “Are you sure you want to create this customer?” Each confirmation step not only prevents accidents but also provides a clear paper trail for auditors. Remember, governing AI means supervising enthusiasm.

Now, about safety. Many organizations sensibly divide knowledge and action credentials. Reading might use a service account with SELECT rights only, while writing requires an elevated connector approved by IT. Copilot Studio allows you to maintain separate connections for these layers, all under the same gateway infrastructure. This separation of duties ensures that even if a configuration misfires, no rogue agent gains write access beyond its intended scope.

Observe how elegantly the gateway handles dual purpose: it translates natural language into T‑SQL both directions, yet keeps authentication centralized. The administrator doesn’t manage dozens of API keys; the gateway proxy manages trust once and replicates it responsibly. Compliance officers rejoice because every write‑back is timestamped, traceable, and reversible. You can open Power Platform telemetry and see precisely which user invoked which action against which table at what time. That’s not automation gone wild; that’s automation domesticated.

Let’s return to the demo example. You instruct Copilot: “Create a new customer record.” It interprets the intent, checks available tools, and finds your Create New Customer Record action. Missing parameters trigger questions until complete. When it finally executes, SQL Server gains an eleventh customer. Refresh the table in Management Studio, and there it is—proof that conversation translated into commerce. Your AI didn’t just summarize reality; it altered it responsibly.

That’s the essence of giving Copilot hands. By exposing a controlled set of SQL actions through the Data Gateway, you empower intelligence to participate in daily operations while retaining the guardrails of enterprise data governance. Each action is a carefully fenced‑off power—bounded capability rather than unlimited access. When configured well, your Copilot becomes both informative and operational, capable of performing transactions, logging every keystroke, and learning proper workplace discipline. Congratulations. You’ve just hired your first digital employee—and built its desk inside SQL Server.

Section 5: Designing the Hybrid Brain — Architecture and Scaling

What you have now is more than a demo; it’s a nervous system. But every nervous system eventually meets reality: lag, failure, and scale. This section is for the architects—the people who must explain to leadership why the Copilot doesn’t melt under enterprise load and why “hybrid” doesn’t secretly mean “fragile.”

Think of the hybrid brain as four organs in one organism. The data source—SQL Server—is the memory cortex, storing knowledge in perfect, tabular patterns. The gateway layer is the spinal cord—transmitting signals both ways while filtering anything unfit for travel. The cloud services—Power Platform and Copilot Studio—are the prefrontal cortex, interpreting language, applying reasoning, managing context. Finally, the front ends—Teams, web chat, mobile—are the mouth and hands, where humans actually interact with the machine. Keep those roles distinct. When one tries to perform another’s function, technical back‑pain ensues.

Resilience begins with redundancy. Deploy multiple gateways on separate servers to form a cluster. They share one identity, one connection reference, but balance the work among themselves. If a single machine crashes or someone casually reboots it during patch week, the others carry on. The Copilot notices nothing. The Power Platform automatically routes connections to the available node—no manual intervention, no downtime. For auditors, the cluster is a comforting diagram: two arrows instead of one failure point.

Next comes load management. Queries generated by Copilot are unpredictable—short text requests one minute, large analytical joins the next. A well‑designed schema prevents those spur‑of‑the‑moment JOIN explosions. Use read‑optimized views, indexed keys, and row‑level filters. The Data Gateway executes SQL on your local network, so it inherits whatever indexes you’ve built. Optimal indexing isn’t an academic suggestion; it’s the reason Copilot answers in seconds rather than sulking in timeout.

Then there’s auditability—the bureaucratic soul of the hybrid brain. Every tool execution, every query, every authentication request surfaces in Power Platform telemetry. Use it. Export logs to Log Analytics or Sentinel, apply filters by user or time, and demonstrate compliance numerically. When your security officer asks, “Who updated the customer table last Thursday?” you can answer with painful precision. Nothing convinces governance like timestamps.

Edge cases deserve mention because they are inevitable. Legacy authentication still lurks—some environments run ancient SQL authentication where the password policy remembers the Bronze Age. Use the gateway’s credential store to hide that embarrassment and rotate keys regularly. Large data models can overwhelm Copilot’s language interface, so summarizing through stored procedures is safer than letting it interpret million‑row JSONs. Dynamic schemas—tables that change weekly—require automated metadata refresh. Schedule those connections to re‑index nightly, so your Copilot doesn’t wake up confused Monday morning.

Security philosophy underpins everything. The goal is not migration; moving your crown‑jewel data to someone else’s cloud isn’t modernization—it’s surrender. The goal is synchronization without exposure. The gateway permits motion without relocation. Data stays in the jurisdiction auditors can visit, while intelligence flows freely to the tools employees actually use. It’s the only equilibrium between control and productivity that scales.

From a design standpoint, document the path: SQL Server (memory) ⟶ Data Gateway (spine) ⟶ Power Platform cloud (brain) ⟶ Teams or web (face). One continuous signal, fully encrypted, auditable at every hop. Once you internalize that pattern, replicating it for other systems becomes trivial. Change SQL for Oracle, or a local API, and the structure remains identical. Congratulations—you’ve just drawn the blueprint for hybrid AI itself.

Conclusion: The Real Secret

So what’s the real secret to putting SQL data in Copilot Studio? It isn’t a command or a hidden switch. It’s architecture—respecting boundaries while designing pathways. Knowledge without connectivity is useless; connectivity without control is dangerous. The Data Gateway resolves that paradox by letting intelligence cross the firewall without ever breaching it.

With SQL as memory and Copilot Studio as reasoning, your organization finally owns a complete digital brain—capable of quoting invoices, adding customers, and learning while remaining inside policy. Real‑time hybrid intelligence isn’t lore; it’s a symptom of wiring done properly.

If this concept saved you another night of exporting CSVs, repay the favor: subscribe. Because next, we extend this architecture to legacy APIs and flat‑file dinosaur systems—teaching Copilot to communicate with everything else still haunting your server rack. The future of AI isn’t another model; it’s proper wiring. Build it right.

Discussion about this episode

User's avatar