Demo Database Seeding
The demo seeding toolkit generates continuous, realistic DML activity (INSERT, UPDATE, and DELETE) against the sample AdventureWorksLT (SalesLT) database. It is designed for demonstrating and testing continuous incremental extractions, Watermark updates, and Change Data Capture (CDC) pipelines without modifying or deleting any original sample rows.
Files Overview
| File | Purpose |
|---|---|
scripts/seed-demo.ps1 |
PowerShell runner that loops small DML ticks on a configurable interval and prints per-table summaries. |
scripts/seed-demo.sql |
Transactional T-SQL script (usable both parameterized via seed-demo.ps1 and standalone in a SQL IDE). |
scripts/cleanup-demo.sql |
Transactional FK-safe cleanup script that deletes only rows tagged by the seeder. |
Target Tables & Row Tagging
Each tick applies inserts, updates, and deletes across six SalesLT tables covering both Watermark (ModifiedDate) and CDC strategies:
| Table | Strategy | Seeder Tag / Scope |
|---|---|---|
SalesLT.Address |
Watermark | AddressLine2 = N'[DEMO-SEED]' |
SalesLT.Customer |
Watermark | CompanyName LIKE N'[[]DEMO-SEED]%' |
SalesLT.SalesOrderHeader |
Watermark | Comment LIKE N'[[]DEMO-SEED]%' |
SalesLT.SalesOrderDetail |
Watermark | Lines belonging to tagged SalesLT.SalesOrderHeader rows |
SalesLT.SalesOrderHeaderEnlarged |
CDC | Comment LIKE N'[[]DEMO-SEED]%' |
SalesLT.SalesOrderDetailEnlarged |
CDC | CarrierTrackingNumber LIKE N'DEMO-%' |
Because every seeded record carries a [DEMO-SEED] or DEMO- marker, original AdventureWorksLT rows are never touched by updates, deletes, or cleanup.
Prerequisites & Connection Configuration
- PowerShell: Windows PowerShell 5.1 or PowerShell 7+ (uses the built-in
.NET System.Data.SqlClientprovider — nosqlcmdinstallation required). - Connection string:
scripts/seed-demo.ps1resolvesMSSQL_CONNin the following precedence order: -ConnectionString "..."parameter$env:MSSQL_CONNenvironment variableMSSQL_CONN=...inside.envat the repository root (or the path passed to-EnvFile)
ODBC/Tiberius/ADO.NET connection string keys (such as Driver, Server, Database, Uid/User ID, Pwd/Password, Encrypt, TrustServerCertificate, and Connection Timeout) are normalized automatically for System.Data.SqlClient. Only Server / Database is logged to the console; credentials are never printed.
Quick Start
# 1. Verify connectivity and current row counts without modifying data
.\scripts\seed-demo.ps1 -DryRun
# 2. Run the default 30-minute loop (every 15 seconds: +3 inserts, ~2 updates, -1 delete per table)
.\scripts\seed-demo.ps1
# 3. Clean up all seeded rows when finished
.\scripts\seed-demo.ps1 -Cleanup
Common Examples
# Custom duration, interval, and batch sizes
.\scripts\seed-demo.ps1 -DurationMinutes 30 -IntervalSeconds 10 -InsertCount 5 -UpdateCount 3 -DeleteCount 1
# Run a single batch tick and exit
.\scripts\seed-demo.ps1 -Once
# Run a single batch tick with custom counts
.\scripts\seed-demo.ps1 -Once -InsertCount 2 -UpdateCount 1 -DeleteCount 1
# Point to a custom .env file
.\scripts\seed-demo.ps1 -EnvFile .\path\to\.env -DryRun
End-to-End Live Demo Workflow
Run the seeder in one terminal while running scheduled extractions or the Web UI in another:
Terminal 1 — Continuous database activity (30 minutes, every 15s):
Terminal 2 — Extractor Web UI or Headless Scheduler:
# Launch the Web UI (includes live runs, schedules, and catalog views)
sql-extractor start --port 8080
# Or run scheduled extractions headlessly
sql-extractor schedule
Press Ctrl+C in Terminal 1 at any time to stop early; the runner wakes up within 1 second, closes the SQL connection cleanly, and prints a cumulative summary across all six tables. When your demo finishes, restore the database to its initial state with:
PowerShell Parameters Reference (scripts/seed-demo.ps1)
| Parameter | Type | Default | Range / Notes | Description |
|---|---|---|---|---|
-DurationMinutes |
int |
30 |
0..1440 |
Total duration to loop before exiting. |
-IntervalSeconds |
int |
15 |
1..3600 |
Wait time between batch ticks (slept in 1-second increments for responsive Ctrl+C). |
-InsertCount |
int |
3 |
0..1000 |
Rows to insert into each target table per tick. |
-UpdateCount |
int |
2 |
0..1000 |
Tagged rows to update in each target table per tick. |
-DeleteCount |
int |
1 |
0..1000 |
Older tagged rows to delete from each target table per tick. |
-Once |
switch |
false |
— | Execute a single batch tick and exit immediately. |
-DryRun |
switch |
false |
— | Verify connection, check all six tables exist, and display total/seeded row counts without writing. |
-Cleanup |
switch |
false |
— | Execute scripts/cleanup-demo.sql to remove all seeded rows and exit. |
-EnvFile |
string |
<repo>\.env |
— | Path to a .env file containing MSSQL_CONN. |
-ConnectionString |
string |
"" |
— | Explicit SQL connection string (overrides $env:MSSQL_CONN and -EnvFile). |
-CommandTimeoutSeconds |
int |
60 |
5..600 |
SQL command timeout per batch execution. |
How Inserts, Updates, and Deletes Work
Every tick runs inside a single transaction (SET XACT_ABORT ON) with a shared @Now = GETUTCDATE() timestamp and a unique @BatchTag (for example, T1-153004):
- Inserts (
@InsertCount): Creates matching addresses, customers, order headers, and order detail rows using existingSalesLT.ProductIDs/prices. ForSalesLT.SalesOrderHeader(whoseSalesOrderIDcolumn is not anIDENTITY), IDs are allocated safely aboveMAX(SalesOrderID). Computed columns (SalesOrderNumber,TotalDue,LineTotal) are omitted and recomputed by SQL Server. - Updates (
@UpdateCount): UpdatesModifiedDate = @Nowalong with mutable fields (PostalCode,CompanyName,Phone,RevisionNumber,Status,Freight,OrderQty,UnitPrice), preferring[DEMO-SEED]rows inserted in previous ticks before falling back to rows created in the current tick. - Deletes (
@DeleteCount): Deletes only older[DEMO-SEED]rows not inserted during the current tick, in FK-safe order (SalesOrderDetail->SalesOrderHeader-> unreferencedCustomer-> unreferencedAddress;SalesOrderDetailEnlarged->SalesOrderHeaderEnlarged). On the very first tick against a clean database,Deletedis0; from tick 2 onward, both CDC and cascade/parent-child deletes are exercised continuously.
During multi-minute runs, if a transient network or SQL error interrupts a tick, seed-demo.ps1 logs a warning, disposes the broken connection, and reconnects automatically on the next interval instead of aborting the session.
Running the SQL Scripts Standalone
Both scripts/seed-demo.sql and scripts/cleanup-demo.sql can also be executed directly in SQL Server Management Studio (SSMS), Azure Data Studio, or the VS Code MSSQL extension:
- Open
scripts/seed-demo.sqland adjust the default parameters at the top of the file if desired:
-- <STANDALONE_PARAMS_START>
DECLARE @InsertCount INT = 3;
DECLARE @UpdateCount INT = 2;
DECLARE @DeleteCount INT = 1;
DECLARE @BatchTag NVARCHAR(40) = N'MANUAL';
-- <STANDALONE_PARAMS_END>
Note: Keep the
-- <STANDALONE_PARAMS_START>and-- <STANDALONE_PARAMS_END>marker comments intact soscripts/seed-demo.ps1can continue stripping that block when passing bound parameters.
- Execute the script once per desired batch; it returns a six-row summary (
TableName,Inserted,Updated,Deleted). - To remove all seeded data later, execute
scripts/cleanup-demo.sql; it returns(TableName, Deleted)for all six tables.