sprocguard
v0.3.1Safety net for SQL Server stored procedures: capture their behavior and verify changes.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
inspect_procedure
Describe a stored procedure: parameters, tables it reads and writes, procedures and triggers involved, and risks (external side effects, dynamic SQL, nondeterminism). Call this first. `procedure` is a name like 'dbo.usp_PlaceOrder'.
| Parameter | Type | Description |
|---|---|---|
procedure * | string | |
include_definition | boolean |
suggest_cases
Suggest parameter values for test cases: real values found in related tables plus edge values (0, -1, empty, NULL). Use them to design cases that cover every branch.
| Parameter | Type | Description |
|---|---|---|
procedure * | string |
capture_baseline
Record what the procedure does TODAY, before you change it. `cases` is a list like [{"name": "customer with orders", "params": {"@CustomerId": 1}}]. Each case runs twice inside a rolled-back transaction; result sets, return value, OUTPUT parameters, errors and table changes are saved to a baseline file. Values that change by themselves (dates, new IDs) are detected and ignored later. `watch_tables` adds tables to compare (useful with dynamic SQL). Refuses to replace an existing baseline unless overwrite=true.
| Parameter | Type | Description |
|---|---|---|
cases * | array | |
procedure * | string | |
overwrite | boolean | |
watch_tables |
verify_procedure
Re-run the baseline cases against the procedure as it is now in the database and list every difference in behavior. Run it after deploying your change to the development database. An empty difference list for every case means the behavior is unchanged.
| Parameter | Type | Description |
|---|---|---|
procedure * | string |
generate_tsqlt_tests
Turn the baseline into tSQLt tests (a .sql file) so the safety net can run in CI. Version 0.1 supports read-only procedures.
| Parameter | Type | Description |
|---|---|---|
procedure * | string |
list_baselines
List the procedures that already have a baseline.