# Northwind tutorial source

The tutorial uses Microsoft's SQL Server Northwind sample, pinned to commit `2f85f3724ee45776a5183ed34d064488a6e1dc53` in the [Microsoft SQL Server samples repository](https://github.com/microsoft/sql-server-samples/tree/2f85f3724ee45776a5183ed34d064488a6e1dc53/samples/databases/northwind-pubs).

| File | SHA-256 |
| --- | --- |
| Upstream `instnwnd.sql` | `3cc62b3fca6d244a47dbde698b809331e4f85988a0685b2b370717d431e94871` |
| `01-load-northwind.sql` | `d6a02c29b2f8065d34ba8fbef93e3479fa4cc63783c0e5876a3fc4f2858c5531` |
| `02-check-northwind.sql` | `fadaa6c17cec1a24d4307de1f7a72e3bc820688eedeebdc10190594606dec0c4` |
| `Microsoft-license.txt` | `201f3705979e932c92cd3c6ddbddf4dc3c71dcc5a82089a1e4018227cfe1cf09` |

Microsoft's copyright and MIT permission notice are included in [Microsoft-license.txt](https://www.analyticscreator.com/hubfs/AnalyticsCreator-Getting-Started-2026-09-30T142235Z/Microsoft-license.txt). The unguarded upstream script is not included in these reader resources. Its original bytes are available at the [pinned source URL](https://raw.githubusercontent.com/microsoft/sql-server-samples/2f85f3724ee45776a5183ed34d064488a6e1dc53/samples/databases/northwind-pubs/instnwnd.sql).

## Load only an empty tutorial database

1. In SSMS, connect to the isolated tutorial SQL Server and select `Northwind` in the query editor's database dropdown. Confirm the server and database, not just the database name in Object Explorer.
2. If the sample already exists, leave it unchanged and run `02-check-northwind.sql`. Do not load it again.
3. For a new empty database only, use the setup account with default schema `dbo`. It needs permission to create the sample's tables, views and stored procedures and insert its rows.
4. Run the entire `01-load-northwind.sql` in one fresh query connection. Do not run selected portions. The database must already exist; the loader does not create it.
5. Run the entire `02-check-northwind.sql` in a fresh query window on `Northwind`. Save the results for comparison after the warehouse load.

The loader removes the upstream replacement batches, preserves its schema and data, and executes the retained batches inside one guarded transaction. It refuses a database whose name is not exactly `Northwind`, an account whose default schema is not `dbo`, an already-open transaction, or a database with existing user objects. A transaction-owned exclusive application lock prevents concurrent copies of this loader. The loader uses `XACT_ABORT` and a rollback handler, validates constraints before committing, and does not drop or overwrite existing objects. Existing Northwind data must pass the read-only check instead of being replaced.

If the first load fails, save the first error, close that failed connection and inspect the isolated tutorial database from a fresh connection. Correct the cause and retry the entire loader only if the database is empty. If objects remain, ask the SQL administrator to inspect them; do not remove existing work to force a retry.

## What the source check establishes

`02-check-northwind.sql` reads permanent source tables and uses temporary tables for its comparison. It does not change the source's permanent tables. It compares all rows of the selected tutorial columns in both directions, checks the selected keys, and compares counts and sales totals.

| Table | Columns compared | Expected rows |
| --- | --- | --- |
| Customers | CustomerID, CompanyName | 91 |
| Orders | OrderID, CustomerID, OrderDate | 830 |
| Products | ProductID, ProductName | 77 |
| Order Details | OrderID, ProductID, UnitPrice, Quantity, Discount | 2,155 |

This is not a check of every column or every Northwind table. The four table results and final result must pass. Net sales use order-line unit price × quantity × (1 − discount), with discount normalized to `decimal(9,4)` and each line rounded to two decimals before summing. All orders are included, with calendar year taken from OrderDate. The expected net sales are `1265793.29`, and expected units are `51317`. Freight is excluded; the tutorial does not assume a currency.

## Prior validation and limits

These two SQL files retain exactly the bytes of the previously reviewed sample. On 29 September 2026, a test copy of the loader ran in a fresh isolated validation database; only its expected database-name literal changed. It refused the wrong database and a nonempty database. An injected error before commit left zero user objects, and a clean retry passed the four source checks. That evidence establishes the isolated loader's guarded first-load behavior, not a reset of an existing source.

The local evidence records identify the exact test files and results. New read-only execution, if performed for this revision, is recorded separately under `research` or `review`. Neither the source check nor the isolated loader test establishes that AnalyticsCreator has generated or loaded the warehouse or produced a working Power BI project.
