SpDev: SQL Server stored procedure debugger and profiler
Step through SQL Server stored procedures in VS Code, the way you step through C#: breakpoints, variables, a call
stack across nested procedures, result sets, errors on the right line, and step back. Free.
Website, documentation and pricing: spdev.app.
With SpDev Pro, you can also profile a procedure line by line. SpDev shows where the time and the reads go,
reads the actual execution plans, and points at the lines that make the procedure slow. It tells you why each one is
slow and gives you the fix.
The debugger (free)
- Open a
.sql file with CREATE PROCEDURE … (or a script).
- Click ▶ Debug above it.
- Enter a connection string to a development database (it's kept in secret storage) and the parameter values.
- Step with F10 / F11 / Shift+F11, continue with F5, and use Step Back to go backwards.
- After a
SELECT has run, hover over *, SELECT or a column name to see the rows it returned.
- Press F10 on the last statement and SpDev stops once more on
END, so you can see what it returned.
SpDev runs your local file, including the local versions of the procedures it calls. Edit and re-run without
deploying.
Debug calls from your app
Add the SpDev.Runtime NuGet package to your app. With EF Core:
builder.Services.AddSpDev(o => o.Enabled = builder.Environment.IsDevelopment());
builder.Services.AddDbContext<AppDb>((sp, o) => o.UseSqlServer(cs).UseSpDev(sp));
With Dapper or plain ADO.NET:
await using var connection = new SqlConnection(cs).WithSpDev(serviceProvider);
Then run SpDev: Attach to Application, set breakpoints and use your app.
SpDev Pro
Click Profile above a procedure (or run SpDev Pro: Profile SQL File). SpDev runs it once and measures every
statement. It shows you the following.
Where the time goes, line by line
- Every line is tinted by how much of the run it took, and its cost is written at the end of the line:
1.24 s (87%) · 48k reads · ×300 · 300 rows.
- Hover a line for the full breakdown: time, CPU, logical and physical reads, writes, rows, executions, the slowest
execution, and what it waited on.
- Time, CPU and I/O come from SQL Server's own counters for your session, corrected for SpDev's own cost. Logical
reads are exact.
Why it's slow, with the fix. SpDev captures the actual execution plans and reads them the way a performance
specialist would. Each finding appears as a problem on the exact line:
- Missing indexes, with the
CREATE INDEX ready to copy. That includes the scans SQL Server itself doesn't flag:
"reads 200,000 rows of dbo.Orders to keep 39".
- Implicit conversions that prevent index seeks (
VARCHAR column, NVARCHAR parameter).
- Parameter sniffing: "compiled for @Kind = 'C', ran with 'A'".
- Bad row estimates, and table variables that hide row counts.
- Key lookups running tens of thousands of times, and the
INCLUDE columns that remove them.
- Functions on columns (
YEAR(CreatedAt) = 2024), with the rewrite that can seek.
- Spills to tempdb and oversized memory grants.
- Scalar functions that run once per row.
- Row-by-row loops and cursors that dominate the run.
- Long transactions holding locks, and statements waiting on locks or disk.
Before and after. Every profile is kept. Profile again after a change and SpDev compares the two runs statement
by statement. Logical reads are deterministic, so you see whether your fix worked, not just whether the server was
quieter this time.
More
- Benchmark: several runs (each rolled back), with the median, p95 and spread of every statement.
- Sandbox runs: debug, run or profile inside a transaction that is rolled back, so testing doesn't change data.
- Coverage: statement and branch coverage of your procedures in VS Code's Test Coverage view, collected across
debug and profile runs. You can see which
IF branches no test reached.
- Report: export a profile, with its findings and the comparison, as Markdown for a ticket or a pull request.
- Calls into other procedures: costs are rolled up per procedure and per call.
No AI is involved. Every finding comes from SQL Server's own measurements and actual plans, so you can check it.
Try it
Run SpDev: Start Free Pro Trial: 14 days, everything included, no card needed. To buy, run SpDev: Buy SpDev Pro,
or see pricing.
Then run SpDev: Activate Pro and paste the licence key from your email. A team licence covers 10 developers; each
seat can be active on two machines. Run SpDev: Pro Licence… to see your licence, free a seat, or use an offline
licence on a machine without internet access.
Activating sends the licence server your key, a hash of VS Code's machine id and the computer's name (shown on the
page where you free seats). After that, SpDev renews the licence once a day. Your SQL, data and connection strings
never leave your machine. The privacy policy has the details. The free debugger never contacts the server at all.
What profiling needs
- A login that can run the procedure. Reading its own counters needs no extra permission.
- For plan insights, the
SHOWPLAN permission in the database (GRANT SHOWPLAN TO [you]). Without it, you still get
the line-by-line costs.
- A development or test database. Profiling runs your code for real; use Profile in a Sandbox to roll back its
changes.
Requirements
- .NET 8 runtime or later (the CLI is bundled).
- SQL Server 2016 or later (tested on SQL Server 2022), or Azure SQL Database.
Settings
| Setting |
Default |
|
spdev.stopOnEntry |
true |
Stop on the first statement |
spdev.stopOnErrors |
true |
Stop on uncaught SQL Server errors |
spdev.traceNestedProcedures |
true |
Use local files for procedures called with EXEC |
spdev.searchDirectories |
[] |
Extra folders with .sql files |
spdev.maxSteps |
20000 |
Snapshot limit per procedure call |
spdev.maxResultRows |
500 |
Rows captured per result set |
spdev.hosting |
auto |
temp never writes to the database; database is needed for user-defined types |
spdev.attachPort |
52341 |
Port for Attach to Application |
spdev.sandbox |
false |
Pro: debug and run inside a transaction that is rolled back |
spdev.profiler.capturePlans |
true |
Pro: capture actual plans for plan insights (needs SHOWPLAN) |
spdev.profiler.heatMetric |
time |
Pro: highlight lines by time, cpu or reads |
spdev.profiler.sandbox |
false |
Pro: profile inside a transaction that is rolled back |
spdev.profiler.openReport |
always |
Pro: open the report after each profile |
spdev.pro.coverage |
true |
Pro: record procedure coverage |
How it works and limitations
- The debugger runs an instrumented copy of your procedure that reports every variable before each statement,
then replays the recording. You can't edit values mid-run.
- The profiler runs a copy that reads SQL Server's counters for your session before each statement. It costs a
few microseconds per statement, measured and subtracted. Timing has 1 ms resolution per measurement, so very short
statements are best compared by reads, or over many executions.
- What isn't traced: dynamic SQL and procedures without a local
.sql file run normally but aren't stepped into.
Their cost and plans are counted on the statement that called them.
- Sandbox runs can't roll back what a procedure commits or rolls back on its own. SpDev tells you when that
happened.
The debugger is MIT-licensed. SpDev Pro is proprietary (see LICENSE).