You Already Speak AI: The SQL Server DBA's Translation Guide

If you run SQL Server for a living, you already speak AI. You just use different words. A prompt is a query. A context window is a memory grant. A tool call is a stored procedure call. And an agent? That's a junior DBA with a runbook.

I made the Oracle version of this video first. This is the SQL Server one, written down. Same idea: no product tour, just a map from what you already know to what's new, and where it can hurt you.

2:15 at night, and the log won't clear

The running example is one we've all had. SalesDB's transaction log is at 97% and it just won't clear. The old way: you open your script folder, your notes, a couple of old blog posts and a search engine. You write the query against sys.databases yourself, run it in SSMS or sqlcmd, and read the result. Every step is yours.

Now you can type the question in plain English. The model drafts the T-SQL, explains the wait or the plan, and an agent can even run read-only queries through a tool. What didn't change: the database is still the source of truth, and you're still the one accountable for what runs on it.

On-prem or Azure doesn't matter much for the AI part. What matters is where the model runs and where your data goes. A local model keeps the data inside. A cloud model is usually stronger, but your prompt leaves the building.

The translation table

AI termWhat you already knowWhy it matters
PromptA query with no parserSQL Server throws Msg 102 on bad syntax. A model just guesses. "Which database uses the most log?" Megabytes or percent? Write prompts like a good ticket.
Tokens8 KB data pagesThe unit of work, cost and every limit. Longer prompts cost more, like more logical reads in STATISTICS IO.
Context windowMemory grantFixed size. When a long chat fills it, the app trims, a bit like a sort that doesn't fit its grant and spills to disk. The middle of a long context gets lost.
Stateless APIA pooled connection after resetA chat only seems to remember because the app resends the whole history every time.
System promptLogon trigger ON ALL SERVERApplied before every request. Put the dialect in it: T-SQL, not Postgres.
HallucinationStale statisticsConfident and wrong. In the video the model invents a column called log_wait_reason. The real one is log_reuse_wait_desc.
Non-determinismNo Query Store to force a planSame question, different T-SQL. Test against a case you already know.
Grounding / RAGCatalog lookupFeed only the slice it needs: sys.columns, sys.foreign_keys, a runbook page.
Tool callStored procedure callThe model only asks. The app executes. The model never touches the database.
MCPPort 1433 + ODBC/JDBC driverOne protocol, many clients and servers. Microsoft ships SQL MCP Server in Data API builder.
Workflow vs agentSQL Agent job vs junior DBAA job has fixed steps. An agent picks its next step from each result.
Human-in-the-loopChange approvalThe agent finds the open transaction. KILL is still your call.

Two queries, one question

"Who holds the oldest open transaction?" I got two answers that both ran fine. One sorted sys.dm_exec_sessions by login_time. That's the oldest login, which may not hold any transaction at all. The other sorted sys.dm_tran_database_transactions by database_transaction_begin_time. Only that one answers the question. This is why you check the result against a small case you already know.

Where the agent stops

SELECT name, log_reuse_wait_desc
FROM sys.databases
WHERE name = N'SalesDB';
-- ACTIVE_TRANSACTION

DBCC OPENTRAN (SalesDB);
-- KILL 87;  → you approve

Ask why, ask who, then stop. Killing that session rolls back its work, and that's a decision a human makes.

What got better, what it costs

The good part: a first T-SQL draft in seconds, plain-English explanations of plans, wait stats and error messages, help on an engine you know less well, and a lot less searching. The bad part: answers can be confidently wrong, the same question can give different results, calls cost tokens and time, and data may leave your network. NIST also names a quieter one, over-reliance. You trust it because it sounds sure, and slowly stop checking.

Security, in DBA words

  1. Prompt injection is SQL injection without parameters. A value in a table row or a line in the error log can say "ignore your rules". With T-SQL you'd fix it with sp_executesql and parameters. There's no such thing for prompts, so limit what the model can do. OWASP lists it as LLM risk number one.
  2. Sensitive data disclosure is an uncontrolled export. Classify before you paste, mask real values, use a local model for anything you wouldn't send outside.
  3. Excessive agency is putting an app login in sysadmin. Give the AI its own login, something like db_datareader, and require human approval for anything high impact.
  4. Avoid the lethal trifecta: private data, untrusted content and a way to send data out. Never all three in one agent.
  5. Passwords and connection strings never go into the chat.
  6. Audit it like any other login. A separate login means sys.fn_get_audit_file shows exactly what it ran. Give the connection its own application name and program_name in sys.dm_exec_sessions tells you which session is the AI.
  7. Production last. Sanitized read-only copy, lab first, human approval, and a database snapshot or a fresh backup before any change.

New words, old habits. Least privilege, review before commit, test before production. If you've done this job for a while, you already have most of the instincts you need.

Full video: You Already Speak AI (SQL Server edition) on YouTube. Session IDs and outputs in the video are illustrative.

Sources

Comments