[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M69AGRAPA61AN2A2N2RF6NCJ":3,"skill-same:01M69AGRAPA61AN2A2N2RF6NCJ":77},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":28,"publishedAt":35,"linkOnly":36,"markdownContent":37,"markdownBody":38,"frontMatter":39,"refName":40,"commitSha":41,"skillDirectory":42,"forksCount":43,"repositoryHtmlUrl":44,"repositoryHomepageUrl":6,"ownerHtmlUrl":45,"ownerBlogUrl":46,"ownerDescription":47,"updatedAt":48,"install":49,"resources":62},"01M69AGRAPA61AN2A2N2RF6NCJ","validate-post-migration-data",null,"Validate data and schema after migrating SQL Server to Azure SQL Database, Azure SQL Managed Instance, or SQL Server on Azure VM. Use after migration, restore, BACPAC import, LRS completion, cutover validation, row-count comparison, or source-target reconciliation.","microsoft\u002Fsqlcon-eu-2026-demos","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M69AFC8P5962CJBG1RDAKA7Q",3,"MIT","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsqlcon-eu-2026-demos\u002Fblob\u002Fmain\u002Fcorenote\u002Fmigration\u002Fskills\u002Fvalidate-post-migration-data\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[29,30,31,32,33,34],"validate","validate post migration data","azure sql","azure sql database","sql","sql server","2026-11-10 10:12:30",false,"---\nname: validate-post-migration-data\ndescription: \"Validate data and schema after migrating SQL Server to Azure SQL Database, Azure SQL Managed Instance, or SQL Server on Azure VM. Use after migration, restore, BACPAC import, LRS completion, cutover validation, row-count comparison, or source-target reconciliation.\"\n---\n\n# Validate data after SQL migration\n\n## When to Use\n\n- Validate schema or data after a SQL Server migration target is online.\n- Compare source and target table inventories, row counts, schemas, or content.\n\nValidate a completed SQL Server database migration against its source without\nchanging data, schema, configuration, security, or database state on either side.\nThis skill supports Azure SQL Database, Azure SQL Managed Instance, and SQL Server\non Azure VM targets.\n\nUse this skill only after the migration skill reports that the target database is\nonline. Migration completion and validation completion are separate states.\n\n## Operating contract\n\n- Default to the `RowCount` profile. It compares the user-table inventory and exact\n  row counts for every mapped table. Run it automatically after migration without\n  a separate validation consent or per-table prompts. Run the broader `Full`\n  profile only when the user explicitly requested schema and content validation.\n- Reuse the source and target server names, database mappings, preserved source\n  and target authentication modes, user principal names for Entra fallback, and\n  secure connection or token-capable routes established by the migration\n  workflow. Execute validation queries through a verified modern Go-based\n  `sqlcmd` executable selected by its full path only when an inherited reusable\n  connection route is unavailable.\n- Reuse the migration workflow's verified target SQL connection handle. If it is\n  unavailable and the handoff specifies `TargetAuthentication=Windows` for a\n  `SQL VM`, use Windows Integrated authentication with `-E`. If the handoff\n  specifies `TargetAuthentication=Entra`, use the cached Microsoft Entra token\n  context through a token-capable in-memory connection adapter. Only as the final\n  Entra fallback, open one attended Microsoft Entra `sqlcmd` login with\n  `-G -U \u003Cuser-principal-name>` and run every target check in that process. Reuse\n  the verified source connection or token-capable route first. If it is\n  unavailable, retain the handoff's `SourceAuthentication` mode: use `-E` for\n  `Windows` or the approved `-G -U \u003Csource-user-principal-name>` route for\n  `Entra`. Permit at most one attended source sign-in for the entire validation\n  run and reuse its authenticated context for both source passes. Never change\n  either endpoint's authentication mode during validation. Never connect to either\n  endpoint with SQL login\u002FSQL authentication. Do not request, accept, retrieve, or\n  use SQL passwords or SQL credentials. Use only Windows Integrated authentication\n  or Microsoft Entra authentication supported by the workflow. Never read SQL credentials from Key\n  Vault or Credential Manager, or display a password prompt. Do not invoke\n  `Connect-AzAccount`, switch identities, or prompt once per pass\u002Ftable.\n  Never echo, print, log, or persist passwords, tokens, connection strings, or\n  access keys, and never place them in command-line arguments or environment\n  variables.\n- Execute only read-only catalog and data queries. Do not issue DDL, DML, `MERGE`,\n  `TRUNCATE`, repair options, configuration changes, statistics updates, or source\n  and target state changes.\n- Never run `DBCC CHECKDB` or another DBCC command against the source as part of\n  post-migration validation.\n- Never enable snapshot isolation, create database snapshots, add helper objects,\n  or change a database to read-only for validation. Use quiesced comparison when\n  the migration handoff provides it. For a writable-source LRS migration, consume\n  the final backup completion time and LSN as the migration cutoff and do not ask\n  for source writes to be paused.\n- Validate one approved source-target database pair at a time. Do not discover or\n  add databases outside the migration manifest.\n- Stop and report `Failed` when the target or required comparison reference is\n  unavailable, the target is not online, permissions are insufficient, or a\n  required query fails. The original source endpoint may be unavailable only for\n  a Continuous LRS handoff that proves it is `RESTORING` and supplies either an\n  immutable cutoff evidence package or a queryable copy restored through the\n  exact final LSN. Never query that restoring source or turn a skipped or\n  incomplete check into a pass.\n- Treat expected target adaptations as explicit, approved exceptions. Do not hide\n  them from the report or count an unapproved difference as a pass.\n- Do not ask for validation scope, table selections, exceptions, output format,\n  evidence retention, timeouts, hash columns, or smoke queries during the default\n  flow. Derive scope and existing exceptions from the immutable migration handoff,\n  use bounded defaults, and record unavailable optional evidence as a limitation.\n  Ask only when a required source\u002Ftarget endpoint is absent or every cached\n  authentication route fails silent renewal. Permit at most one attended target\n  authentication attempt for the complete validation run. A query failure is\n  reported in the result; it is not a prompt.\n\n## Required context\n\nConsume these values from the migration handoff:\n\n| Value | Requirement |\n| --- | --- |\n| Source | Server\u002Finstance and database; preserved authentication mode (`Windows` or `Entra`); reusable connection or token-capable route; Entra user principal name only for attended fallback; plus a queryable source, an immutable profile-complete cutoff evidence package, or a separately restored queryable copy through the final LSN. A Continuous LRS source in `RESTORING` must use one of the latter two references |\n| Target | Target type (`SQL DB`, `SQL MI`, or `SQL VM`), server\u002Finstance, database, preserved authentication mode (`Windows` or `Entra`), reusable connection, Microsoft Entra token route when applicable, and Entra user principal name only for Entra fallback login |\n| Scope | Immutable source-target database mappings from the migration manifest |\n| Consistency | Comparison mode (`Quiesced` or `Writable source with cutoff`), cutover timestamp, and final backup LSN\u002Ffile when applicable |\n| Profile | Default `RowCount`; `Full` only when explicitly requested before validation starts |\n| Exceptions | Inherit approved object exclusions and intentional target adaptations; default to none |\n| Evidence | Reuse the migration evidence location and retention; otherwise return the report in memory\u002Fchat without prompting |\n\nDo not redisplay or reconfirm a complete immutable handoff. Ask once for all\nmissing required nonsecret endpoint values. Test the inherited target connection\nfirst. For an Entra handoff, test the cached Microsoft Entra token context silently\nbefore showing authentication UI and permit one attended Microsoft Entra sign-in\nonly when both Entra routes are unusable. For a Windows-authenticated SQL VM\nhandoff, use `-E` if the inherited handle is unavailable; do not show Entra\nauthentication UI. Apply the same rules independently to the source: never infer\nits mode from its hosting location, never substitute the target identity, and\nnever silently switch between Windows and Entra. Reject SQL login authentication;\ndo not request a password in\nchat, a masked control, or a native `sqlcmd` prompt.\n\n## sqlcmd prerequisite and connection contract\n\nBefore connecting to either endpoint, inspect every `sqlcmd` executable on `PATH`.\nDo not accept the first result merely because it is named `sqlcmd`; older ODBC and\nmodern Go-based clients can coexist. Select a candidate only when `--version`\nsucceeds. Inspect both modern help (`--help`) and SQLCMD-compatible help (`-?`),\nthen require the successful help outputs to collectively expose `-E`, `-G`, and\n`-U`. Current Go `sqlcmd` builds differ in where they list compatibility flags,\nso always try both before rejecting a candidate:\n\n```powershell\nfunction Find-CompatibleGoSqlcmd {\n  param(\n    [string[]]$RequiredFlags = @('-E', '-G', '-U')\n  )\n\n  foreach ($candidate in @(Get-Command sqlcmd -All -ErrorAction SilentlyContinue)) {\n    $versionOutput = & $candidate.Source --version 2>&1 | Out-String\n    if ($LASTEXITCODE -ne 0) {\n      continue\n    }\n\n    $modernHelpOutput = & $candidate.Source --help 2>&1 | Out-String\n    $modernHelpSucceeded = $LASTEXITCODE -eq 0\n    $compatibilityHelpOutput = & $candidate.Source -? 2>&1 | Out-String\n    $compatibilityHelpSucceeded = $LASTEXITCODE -eq 0\n\n    $missingFlags = @($RequiredFlags | Where-Object {\n      $pattern = \"(?m)(^|\\s)$([regex]::Escape($_))([,\\s]|$)\"\n      -not (\n        ($modernHelpSucceeded -and $modernHelpOutput -match $pattern) -or\n        ($compatibilityHelpSucceeded -and\n          $compatibilityHelpOutput -match $pattern)\n      )\n    })\n\n    if (($modernHelpSucceeded -or $compatibilityHelpSucceeded) -and\n        $missingFlags.Count -eq 0) {\n      return [pscustomobject]@{\n        Path      = $candidate.Source\n        Version   = $versionOutput.Trim()\n        HelpModes = @(\n          if ($modernHelpSucceeded) { '--help' }\n          if ($compatibilityHelpSucceeded) { '-?' }\n        ) -join ', '\n      }\n    }\n  }\n\n  return $null\n}\n\n$modernSqlcmd = Find-CompatibleGoSqlcmd -RequiredFlags @('-E', '-G', '-U')\n```\n\nIf no candidate passes and the migration workflow's preparation consent covers a\nCurrentUser tool install, run the official Windows package command without another\nprompt. Otherwise ask once for approval. Refresh the current process `PATH`, and\nvalidate again:\n\n```powershell\nwinget install sqlcmd --accept-package-agreements --accept-source-agreements\nif ($LASTEXITCODE -ne 0) {\n  throw 'Modern sqlcmd installation failed.'\n}\n\n$refreshedPathSegments = @(\n  $env:Path\n  [Environment]::GetEnvironmentVariable('Path', 'Machine')\n  [Environment]::GetEnvironmentVariable('Path', 'User')\n) | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }\n$env:Path = $refreshedPathSegments -join ';'\n$modernSqlcmd = Find-CompatibleGoSqlcmd -RequiredFlags @('-E', '-G', '-U')\nif (-not $modernSqlcmd) {\n  throw 'Modern sqlcmd was installed but could not be validated. Open a new terminal and retry.'\n}\n```\n\nIf installation is declined, `winget` is unavailable, or validation still fails,\nstop before connecting and provide\n`https:\u002F\u002Flearn.microsoft.com\u002Fsql\u002Ftools\u002Fsqlcmd\u002Fsqlcmd-download-install`. Never run\nan unqualified `sqlcmd`; invoke `$modernSqlcmd.Path` so an older executable earlier\non `PATH` cannot be selected accidentally.\n\nCreate access-controlled local `.sql` files for the read-only query batches and\nseparate source and target output files. Query files must not contain credentials,\ntokens, connection strings, DDL, DML, DBCC, or `:!!` shell commands. Put both\ntarget passes in one query file and one `sqlcmd` process so attended Entra\nauthentication occurs at most once when the reusable target connection and cached\ntoken adapter are unavailable. Bracket that target process with the two\nnoninteractive Windows-authenticated source passes:\n\nThe following direct-source process applies only while the original source is\nqueryable. If the handoff marks it `RESTORING`, do not execute either source\nprocess. Instead, validate the evidence package hash and cutoff binding and use\nits normalized inventory\u002Fcount records as source passes, or run both source\npasses against the separately restored cutoff copy. Before using these fallback\nprocesses, try the handoff's reusable source connection and token-capable route.\nFor an Entra fallback, silently reuse the cached authentication context and allow\nat most one attended sign-in across both source passes.\n\n```powershell\n$sourceAuthenticationArguments = @(switch ($sourceAuthentication) {\n  'Windows' {\n    @('-E')\n    break\n  }\n  'Entra' {\n    if ([string]::IsNullOrWhiteSpace($sourceUserPrincipalName)) {\n      throw 'The Entra source handoff does not contain a user principal name for attended fallback.'\n    }\n    @('-G', '-U', $sourceUserPrincipalName)\n    break\n  }\n  default {\n    throw \"Unsupported source authentication mode '$sourceAuthentication'.\"\n  }\n})\n\n& $modernSqlcmd.Path -S $sourceServer -d $sourceDatabase `\n  @sourceAuthenticationArguments -b -r1 -h -1 -W -s '|' -w 65535 `\n  -i $sourcePassAQueryPath -o $sourcePassAOutputPath\nif ($LASTEXITCODE -ne 0) {\n  throw \"Source validation pass A failed with exit code $LASTEXITCODE.\"\n}\n\n$targetAuthenticationArguments = @(switch ($targetAuthentication) {\n  'Windows' {\n    if ($targetType -ne 'SQL VM') {\n      throw 'Windows target authentication is supported only for a SQL VM handoff.'\n    }\n    @('-E')\n    break\n  }\n  'Entra' {\n    if ([string]::IsNullOrWhiteSpace($targetUserPrincipalName)) {\n      throw 'The Entra target handoff does not contain a user principal name for attended fallback.'\n    }\n    @('-G', '-U', $targetUserPrincipalName)\n    break\n  }\n  default {\n    throw \"Unsupported target authentication mode '$targetAuthentication'.\"\n  }\n})\n\n& $modernSqlcmd.Path -S $targetServer -d $targetDatabase `\n  @targetAuthenticationArguments -b -r1 -h -1 -W -s '|' -w 65535 `\n  -i $targetPassesQueryPath -o $targetPassesOutputPath\nif ($LASTEXITCODE -ne 0) {\n  throw \"Target validation passes failed with exit code $LASTEXITCODE.\"\n}\n\n& $modernSqlcmd.Path -S $sourceServer -d $sourceDatabase `\n  @sourceAuthenticationArguments -b -r1 -h -1 -W -s '|' -w 65535 `\n  -i $sourcePassBQueryPath -o $sourcePassBOutputPath\nif ($LASTEXITCODE -ne 0) {\n  throw \"Source validation pass B failed with exit code $LASTEXITCODE.\"\n}\n```\n\nUse `-C` only when trusting the presented server certificate is an explicitly\naccepted environment policy. Otherwise configure a verifiable certificate and\nomit `-C`. Treat a nonzero `sqlcmd` exit code, missing output, malformed result, or\ninteractive-login cancellation as `Fail`. Normalize and compare the structured\nsource and target result sets in memory; never infer a match from console text or\na zero exit code alone.\n\nUse strict pipe-delimited rows for every validation result. Do not use `FOR JSON`,\n`FOR XML`, formatted tables, or a split limit. Prefix each row with one of the\ndeclared record types (`META`, `INVENTORY`, `COUNT`, `ERROR`, or `CUTOFF`), run\n`SET NOCOUNT ON`, split on every `|`, and require the exact field count for that\nrecord type. Encode nullable text as `~` for `NULL`, otherwise prefix it with\n`v:` and replace `%`, `|`, CR, and LF with `%25`, `%7C`, `%0D`, and `%0A`\nrespectively. Decode in reverse replacement order with `%25` last. Convert\n`COUNT_BIG`, compatibility levels, isolation levels, and Boolean values to their\ndeclared PowerShell types; malformed, duplicate, missing, or unknown rows fail\nvalidation.\n\nSelect the database only with the `sqlcmd -d` argument. Do not put `USE` in a\nmachine-read query batch because its context message can contaminate delimited\noutput. Capture `$LASTEXITCODE` immediately after each `sqlcmd` process, before\nACL updates, output parsing, or any other native command.\n\nWhen constructing the one target file containing passes A and B, terminate each\npass and place `GO` on its own line. Join generated fragments with an explicit\nnewline; never concatenate strings in a way that can produce `GOSET`:\n\n```powershell-pseudocode\n$targetPassesSql = @(\n  (New-ValidationPass -Pass 'A').TrimEnd()\n  'GO'\n  (New-ValidationPass -Pass 'B').TrimEnd()\n  'GO'\n) -join [Environment]::NewLine\n```\n\n## Status model\n\nEvery validation scenario has one of these statuses:\n\n- `In progress`: started but not yet conclusively completed.\n- `Pass`: completed and matched, or an approved exception matched its expectation.\n- `Inconclusive`: the check completed, but a writable source changed or differs\n  from the target and no cutoff-consistent source reference exists to distinguish\n  expected post-cutoff activity from a migration difference.\n- `Fail`: proven mismatch, query failure, source change in `Quiesced` mode,\n  unexpected target change, unsupported required check, or missing required\n  evidence.\n\nThe database result is `Pass` only when every required scenario passes and the\ncomparison boundary is proven. It is `Ready with conditions` when every measured\nscenario is `Pass` or `Inconclusive`, no scenario failed, and a writable source\nprevents exact point-in-time equality from being proven. It remains `In progress`\nwhile a required scenario is running and is `Fail` when any required scenario\nfails. Do not turn a proven cutoff mismatch, missing target table, or query failure\ninto `Ready with conditions`.\n\n## Workflow\n\n```text\nPhase 0  Accept the handoff and prove read-only access without reconfirmation\nPhase 1  Compare the complete user-table inventory\nPhase 2  Capture exact source and target row-count pass A\nPhase 3  Recapture exact target and source row-count pass B\nPhase 4  Run schema\u002Fcontent checks only for the explicit Full profile\nPhase 5  Classify stability and cutoff evidence, then publish one report\n```\n\nThe `RowCount` profile runs Phases 0-3 and 5. It does not ask whether to run Phase\n4. The `Full` profile runs all phases. Prefer the inherited target connection for\nall target-side checks. On fallback, use one target `sqlcmd` process for both\ntarget passes so interactive authentication is not repeated per table or phase.\n\n## Phase 0 - Handoff and safety gates\n\n1. Load the source-target mapping and target type from the immutable migration\n  manifest without asking the user to confirm them again.\n2. Resolve and validate modern `sqlcmd`, reusing the migration workflow's tool\n  installation consent when it is absent; otherwise ask once.\n3. Test and reuse the inherited source and target connections independently. For\n  an Entra source, try its inherited token-capable route silently before using\n  the approved `-G -U \u003Csource-user-principal-name>` fallback, with at most one\n  attended source sign-in for the run. For a Windows source, use `-E` only when\n  its inherited handle is unavailable. If the target connection is unavailable, try the\n  cached Microsoft Entra token context silently for an Entra handoff. Use\n  `-G -U \u003Cuser-principal-name>` once only when both Entra routes fail. For a\n  Windows-authenticated SQL VM handoff, retain that mode and use `-E` when the\n  inherited target handle is unavailable. Do not infer source authentication\n  from an on-premises location or silently switch either endpoint's identity.\n  Verify the actual server and database identity returned by each endpoint.\n4. Verify the target database is online and queryable.\n5. Determine the comparison mode from the migration handoff. For `Quiesced`,\n  confirm the source remains quiesced. For `Writable source with cutoff`, verify\n  the final backup file, completion time, and LSN from the immutable manifest;\n  use a hash-verified immutable source evidence package captured while quiesced or\n  a separately restored copy at that exact LSN. When the original source is\n  `RESTORING`, do not connect to it. Reject a missing, mismatched, or incomplete\n  cutoff reference rather than degrading to current-source observation.\n6. Verify the principal can read catalog metadata and `SELECT` every in-scope user\n   table. Insufficient visibility is a failure, not a zero count.\n7. Create the in-memory scenario manifest with all checks set to `In progress` and\n  proceed automatically. Do not ask for permission to execute read-only queries.\n\nDo not impersonate a broader principal or grant permissions as part of validation.\n\n## Phase 1 - Inventory and baseline fingerprints\n\nOn both endpoints, capture before-values without changing either database:\n\n- Actual server, database, engine edition, database state, collation, and\n  compatibility level where exposed by the target.\n- Maximum `modify_date` for user objects and the count of user objects.\n- A deterministic hash of the normalized user-object inventory and schema metadata\n  collected in Phase 2.\n- Per-table row counts collected in Phase 3, timestamped in UTC.\n- Source quiescence evidence or writable-source cutoff file\u002Ftime\u002FLSN from the\n  migration handoff.\n\nFor `RowCount`, compare the complete normalized `(schema, table)` inventory before\ncounting. A source table missing on target or an unexpected target table is a\n`Fail`, unless it exactly matches an inherited approved exception. This inventory\ngate prevents a row-count run from silently skipping a missing table. Full column,\nconstraint, module, and permission comparison belongs to the `Full` profile.\n\nA catalog `modify_date` does not detect data changes, so row counts and optional\ncontent signatures must also be recaptured in Phase 5. Record isolation level and\nwhether source quiescence was independently confirmed. Do not change isolation or\ndatabase options to improve consistency.\n\n## Phase 2 - Object and schema comparison\n\nFor `RowCount`, execute only the user-table inventory subset described in Phase 1\nand continue directly to Phase 3. Do not ask whether to run the remaining checks.\nFor `Full`, compare the complete schema below.\n\nCompare source and target counts and detailed inventories by schema and object\nname for all supported user objects:\n\n- schemas, tables, views, stored procedures, scalar\u002Ftable functions, synonyms,\n  sequences, and user-defined types;\n- columns, data types, lengths, precision, scale, nullability, collation, identity,\n  computed-column definitions, and defaults;\n- primary keys, unique\u002Fcheck\u002Fdefault constraints, foreign keys and referential\n  actions;\n- indexes and indexed columns, including uniqueness, filters, and disabled state;\n- triggers, temporal-table metadata, and partition metadata;\n- database users, roles, role membership, and explicit database permissions when\n  they are in migration scope.\n\nIgnore Microsoft-shipped objects. Compare normalized module definitions when the\nprincipal has metadata visibility. If a definition is encrypted or unavailable,\nreport that object as failed unless it is an approved exception. Account for\nplatform differences only through the approved exception list, especially SQL\nAgent and server-scoped objects that do not exist in Azure SQL Database.\n\nFor every mismatch, record the scenario, source object name, target object name,\nsource value, target value, and a concise reason such as `Missing on target`,\n`Unexpected on target`, or `Column precision differs`.\n\n## Phase 3 - Exact row-count comparison\n\nCompare an exact `COUNT_BIG(*)` for every in-scope user table on source and target.\nCatalog partition row estimates may be used to plan the run, but never as pass\nevidence. Generate table-specific statements only from catalog values returned by\nthe approved database and quote every identifier with `QUOTENAME`; never\ninterpolate an unvalidated identifier into a local query file.\n\nProcess tables in deterministic schema\u002Fname order. Generate one read-only batch per\nendpoint pass and return structured rows containing database, schema, table,\n`COUNT_BIG`, pass identifier, and UTC query timestamps. Never parse formatted table\noutput. A timeout, permission error, unsupported object, duplicate\u002Fmissing output\nrow, or interrupted query is a `Fail` for that table, not `0` and not `Pass`. Retry\none transient connection failure with the same authenticated session; do not prompt\nper table or silently reduce scope.\n\nUse `QUOTENAME` for every catalog-derived identifier and isolate each dynamic\n`COUNT_BIG(*)` in `TRY\u002FCATCH` so one table error is recorded and later tables still\nrun. Do not use `NOLOCK`, `READ UNCOMMITTED`, partition metadata, or approximate\ncounts as equality evidence. Do not introduce stronger isolation that blocks source\nwrites. Record that two equal count passes cannot detect same-count row updates.\n\nWhen the original source is queryable, run the passes in this order:\n\n1. Source pass A.\n2. Target pass A.\n3. Target pass B.\n4. Source pass B.\n\nWhen it is `RESTORING`, substitute the verified immutable evidence package's two\nsource passes, or execute source passes A and B against the separately restored\ncutoff copy. Validate that the reference names the same database, final file,\ncompletion time, and final LSN as the handoff before comparing any target count.\n\nThis brackets the target observations with source observations and detects changes\nduring the validation window. Use a cutoff reference automatically when the\nmigration handoff contains either a queryable validation copy restored through the\nfinal backup LSN or table counts captured from a transactionally consistent source\nsnapshot at that cutoff. Do not ask the user to create such a reference during\npost-migration validation.\n\nClassify each mapped table as follows:\n\n| Evidence | Result |\n| --- | --- |\n| Target A differs from target B | `Fail`: target changed during validation |\n| Quiesced or cutoff reference is stable and differs from target | `Fail`: proven mismatch |\n| Quiesced or cutoff reference is stable and equals target | `Pass` |\n| Writable source, no cutoff reference, source A equals source B and target equals that value | `Pass` observed; database remains `Ready with conditions` |\n| Writable source, no cutoff reference, source changed or its stable current count differs from target | `Inconclusive`: possible post-cutoff divergence |\n| Any required count is unavailable or malformed | `Fail`: validation did not complete |\n\nNever infer cutoff equality from current writable-source counts. Current source\ncounts are evidence of observed state only. A row-count match proves quantity, not\nrow content; state that limitation instead of upgrading it to full data equality.\n\nFor each table report:\n\n| Field | Value |\n| --- | --- |\n| Scenario | `Exact row count` |\n| Object | `\u003Cschema>.\u003Ctable>` |\n| Source pass A \u002F B | `\u003CCOUNT_BIG result>` \u002F `\u003CCOUNT_BIG result>` |\n| Target pass A \u002F B | `\u003CCOUNT_BIG result>` \u002F `\u003CCOUNT_BIG result>` |\n| Cutoff reference | `\u003CCOUNT_BIG result>`, `Not available`, or `Not applicable` |\n| Status | `Pass`, `Inconclusive`, `Fail`, or `In progress` |\n| Reason | Empty on pass; concise instability, limitation, mismatch, or error otherwise |\n\nA matching row count proves quantity, not content. Continue with Phase 4.\n\n## Phase 4 - Full-profile read-only checks\n\nSkip this phase automatically for `RowCount`. For an explicitly requested `Full`\nprofile, run these additional read-only checks without asking for individual\napproval:\n\n- Compare identity current values, sequence current values, temporal-table row\n  counts, and min\u002Fmax temporal periods where applicable.\n- Compare null counts, minimum, maximum, and deterministic aggregates for approved\n  critical columns where data types support them.\n- For critical tables with a stable primary\u002Funique key, compare deterministic\n  key-range chunks using an approved content-hash implementation. Canonicalize\n  nulls, binary values, date\u002Ftime precision, collation-sensitive text, and numeric\n  representation identically on both sides. Record the algorithm and chunk ranges.\n- Run approved read-only application smoke queries. Writes and transaction tests\n  belong to cutover testing and are outside this read-only skill.\n\nDo not use `CHECKSUM_AGG(BINARY_CHECKSUM(*))` as sole proof of equality because\ncollisions and unsupported types can hide differences. Content checks supplement,\nbut do not replace, exact row counts and schema comparison.\n\n## Phase 5 - Change detection and report\n\nUse the A\u002FB results already captured in Phases 2 and 3. For `Full`, also compare\nthe content signatures captured by that profile:\n\n- If this workflow issued any mutating statement, stop and report a safety failure.\n- In `Quiesced` mode, if source schema, source row counts, or source content\n  signatures changed, fail affected consistency scenarios with reason\n  `Source changed during validation`.\n- In `Writable source with cutoff` mode, compare the target with a valid cutoff\n  reference when one exists. Without one, classify changed or differing current\n  source counts as `Inconclusive`, not `Fail`, because current source state is not\n  the migration boundary. Return `Ready with conditions` when there are no failures.\n  An invalid cutoff manifest\u002Fchain or a proven cutoff mismatch is `Fail`.\n- If target schema, target row counts, or target content signatures changed, fail\n  affected scenarios with reason `Target changed during validation`.\n- A metadata timestamp change without a normalized schema difference is still\n  reported for review but does not by itself prove a schema change.\n\nThis skill guarantees that its own workflow is read-only. It detects covered\nexternal changes during the validation window; it cannot guarantee that unmeasured\ncontent did not change when full content signatures were not approved.\n\n## Result presentation\n\nKeep the complete failure list in the in-memory validation result and approved\nevidence report. In chat, display at most 10 failed objects at a time in stable\nscenario, database, schema, and object-name order.\n\nWhen more than 10 failures exist:\n\n- Show `Failures 1-10 of \u003Ctotal>` and the report location.\n- Do not open a `Next` prompt. The complete stable result set remains in the report.\n- Include `Inconclusive` tables in a separate summary and report section; do not\n  present them as migration failures.\n\n## Result format\n\nProduce a sanitized Markdown report and, when requested, a machine-readable JSON\nreport. Never include credentials or secret-bearing connection properties.\n\n```markdown\n# Post-migration data validation report\n\n- Source: \u003Csanitized server\u002Fdatabase>\n- Target: \u003Ctarget type and sanitized server\u002Fdatabase>\n- Validation profile: \u003CRowCount | Full>\n- Validation window: \u003CUTC start> to \u003CUTC finish>\n- Overall status: \u003CPass | Ready with conditions | Fail | In progress>\n- Comparison mode: \u003CQuiesced | Writable source with cutoff>\n- Migration cutoff: \u003Cfinal backup UTC completion time, LSN, and file | Not applicable>\n- Source unchanged during validation: \u003CYes | No | Not fully proven>\n- Target unchanged during validation: \u003CYes | No | Not fully proven>\n\n| Validation scenario | Status | Passed | Inconclusive | Failed | In progress | Notes |\n| --- | --- | ---: | ---: | ---: | ---: | --- |\n| Object inventory | \u003Cstatus> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Csummary> |\n| Schema definitions | \u003Cstatus or Not run> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Csummary> |\n| Exact row counts | \u003Cstatus> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Csummary> |\n| Critical data content | \u003Cstatus or Not run> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Csummary> |\n| Change detection | \u003Cstatus> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Csummary> |\n\n## Failed objects\n\n| # | Scenario | Object | Status | Reason |\n| ---: | --- | --- | --- | --- |\n| 1 | \u003Cscenario> | \u003Cdatabase.schema.object> | Fail | \u003Creason> |\n```\n\nFor `RowCount`, state prominently that exact table counts were compared but row\ncontent and complete schema equality were not validated. Include all A\u002FB counts\nand query timestamps in the machine-readable or evidence report even when chat\nshows only the summary.\n\nInclude approved exceptions, checks not fully proven, query timestamps, isolation,\nquiescence or cutoff evidence, expected post-cutoff divergence, content-hash\nalgorithms and ranges, and the report\u002Fevidence\nlocation. A failure row must always identify the object when one exists and explain\nthe reason. For database-level failures, use the database name as the object.\n","# Validate data after SQL migration\n\n## When to Use\n\n- Validate schema or data after a SQL Server migration target is online.\n- Compare source and target table inventories, row counts, schemas, or content.\n\nValidate a completed SQL Server database migration against its source without\nchanging data, schema, configuration, security, or database state on either side.\nThis skill supports Azure SQL Database, Azure SQL Managed Instance, and SQL Server\non Azure VM targets.\n\nUse this skill only after the migration skill reports that the target database is\nonline. Migration completion and validation completion are separate states.\n\n## Operating contract\n\n- Default to the `RowCount` profile. It compares the user-table inventory and exact\n  row counts for every mapped table. Run it automatically after migration without\n  a separate validation consent or per-table prompts. Run the broader `Full`\n  profile only when the user explicitly requested schema and content validation.\n- Reuse the source and target server names, database mappings, preserved source\n  and target authentication modes, user principal names for Entra fallback, and\n  secure connection or token-capable routes established by the migration\n  workflow. Execute validation queries through a verified modern Go-based\n  `sqlcmd` executable selected by its full path only when an inherited reusable\n  connection route is unavailable.\n- Reuse the migration workflow's verified target SQL connection handle. If it is\n  unavailable and the handoff specifies `TargetAuthentication=Windows` for a\n  `SQL VM`, use Windows Integrated authentication with `-E`. If the handoff\n  specifies `TargetAuthentication=Entra`, use the cached Microsoft Entra token\n  context through a token-capable in-memory connection adapter. Only as the final\n  Entra fallback, open one attended Microsoft Entra `sqlcmd` login with\n  `-G -U \u003Cuser-principal-name>` and run every target check in that process. Reuse\n  the verified source connection or token-capable route first. If it is\n  unavailable, retain the handoff's `SourceAuthentication` mode: use `-E` for\n  `Windows` or the approved `-G -U \u003Csource-user-principal-name>` route for\n  `Entra`. Permit at most one attended source sign-in for the entire validation\n  run and reuse its authenticated context for both source passes. Never change\n  either endpoint's authentication mode during validation. Never connect to either\n  endpoint with SQL login\u002FSQL authentication. Do not request, accept, retrieve, or\n  use SQL passwords or SQL credentials. Use only Windows Integrated authentication\n  or Microsoft Entra authentication supported by the workflow. Never read SQL credentials from Key\n  Vault or Credential Manager, or display a password prompt. Do not invoke\n  `Connect-AzAccount`, switch identities, or prompt once per pass\u002Ftable.\n  Never echo, print, log, or persist passwords, tokens, connection strings, or\n  access keys, and never place them in command-line arguments or environment\n  variables.\n- Execute only read-only catalog and data queries. Do not issue DDL, DML, `MERGE`,\n  `TRUNCATE`, repair options, configuration changes, statistics updates, or source\n  and target state changes.\n- Never run `DBCC CHECKDB` or another DBCC command against the source as part of\n  post-migration validation.\n- Never enable snapshot isolation, create database snapshots, add helper objects,\n  or change a database to read-only for validation. Use quiesced comparison when\n  the migration handoff provides it. For a writable-source LRS migration, consume\n  the final backup completion time and LSN as the migration cutoff and do not ask\n  for source writes to be paused.\n- Validate one approved source-target database pair at a time. Do not discover or\n  add databases outside the migration manifest.\n- Stop and report `Failed` when the target or required comparison reference is\n  unavailable, the target is not online, permissions are insufficient, or a\n  required query fails. The original source endpoint may be unavailable only for\n  a Continuous LRS handoff that proves it is `RESTORING` and supplies either an\n  immutable cutoff evidence package or a queryable copy restored through the\n  exact final LSN. Never query that restoring source or turn a skipped or\n  incomplete check into a pass.\n- Treat expected target adaptations as explicit, approved exceptions. Do not hide\n  them from the report or count an unapproved difference as a pass.\n- Do not ask for validation scope, table selections, exceptions, output format,\n  evidence retention, timeouts, hash columns, or smoke queries during the default\n  flow. Derive scope and existing exceptions from the immutable migration handoff,\n  use bounded defaults, and record unavailable optional evidence as a limitation.\n  Ask only when a required source\u002Ftarget endpoint is absent or every cached\n  authentication route fails silent renewal. Permit at most one attended target\n  authentication attempt for the complete validation run. A query failure is\n  reported in the result; it is not a prompt.\n\n## Required context\n\nConsume these values from the migration handoff:\n\n| Value | Requirement |\n| --- | --- |\n| Source | Server\u002Finstance and database; preserved authentication mode (`Windows` or `Entra`); reusable connection or token-capable route; Entra user principal name only for attended fallback; plus a queryable source, an immutable profile-complete cutoff evidence package, or a separately restored queryable copy through the final LSN. A Continuous LRS source in `RESTORING` must use one of the latter two references |\n| Target | Target type (`SQL DB`, `SQL MI`, or `SQL VM`), server\u002Finstance, database, preserved authentication mode (`Windows` or `Entra`), reusable connection, Microsoft Entra token route when applicable, and Entra user principal name only for Entra fallback login |\n| Scope | Immutable source-target database mappings from the migration manifest |\n| Consistency | Comparison mode (`Quiesced` or `Writable source with cutoff`), cutover timestamp, and final backup LSN\u002Ffile when applicable |\n| Profile | Default `RowCount`; `Full` only when explicitly requested before validation starts |\n| Exceptions | Inherit approved object exclusions and intentional target adaptations; default to none |\n| Evidence | Reuse the migration evidence location and retention; otherwise return the report in memory\u002Fchat without prompting |\n\nDo not redisplay or reconfirm a complete immutable handoff. Ask once for all\nmissing required nonsecret endpoint values. Test the inherited target connection\nfirst. For an Entra handoff, test the cached Microsoft Entra token context silently\nbefore showing authentication UI and permit one attended Microsoft Entra sign-in\nonly when both Entra routes are unusable. For a Windows-authenticated SQL VM\nhandoff, use `-E` if the inherited handle is unavailable; do not show Entra\nauthentication UI. Apply the same rules independently to the source: never infer\nits mode from its hosting location, never substitute the target identity, and\nnever silently switch between Windows and Entra. Reject SQL login authentication;\ndo not request a password in\nchat, a masked control, or a native `sqlcmd` prompt.\n\n## sqlcmd prerequisite and connection contract\n\nBefore connecting to either endpoint, inspect every `sqlcmd` executable on `PATH`.\nDo not accept the first result merely because it is named `sqlcmd`; older ODBC and\nmodern Go-based clients can coexist. Select a candidate only when `--version`\nsucceeds. Inspect both modern help (`--help`) and SQLCMD-compatible help (`-?`),\nthen require the successful help outputs to collectively expose `-E`, `-G`, and\n`-U`. Current Go `sqlcmd` builds differ in where they list compatibility flags,\nso always try both before rejecting a candidate:\n\n```powershell\nfunction Find-CompatibleGoSqlcmd {\n  param(\n    [string[]]$RequiredFlags = @('-E', '-G', '-U')\n  )\n\n  foreach ($candidate in @(Get-Command sqlcmd -All -ErrorAction SilentlyContinue)) {\n    $versionOutput = & $candidate.Source --version 2>&1 | Out-String\n    if ($LASTEXITCODE -ne 0) {\n      continue\n    }\n\n    $modernHelpOutput = & $candidate.Source --help 2>&1 | Out-String\n    $modernHelpSucceeded = $LASTEXITCODE -eq 0\n    $compatibilityHelpOutput = & $candidate.Source -? 2>&1 | Out-String\n    $compatibilityHelpSucceeded = $LASTEXITCODE -eq 0\n\n    $missingFlags = @($RequiredFlags | Where-Object {\n      $pattern = \"(?m)(^|\\s)$([regex]::Escape($_))([,\\s]|$)\"\n      -not (\n        ($modernHelpSucceeded -and $modernHelpOutput -match $pattern) -or\n        ($compatibilityHelpSucceeded -and\n          $compatibilityHelpOutput -match $pattern)\n      )\n    })\n\n    if (($modernHelpSucceeded -or $compatibilityHelpSucceeded) -and\n        $missingFlags.Count -eq 0) {\n      return [pscustomobject]@{\n        Path      = $candidate.Source\n        Version   = $versionOutput.Trim()\n        HelpModes = @(\n          if ($modernHelpSucceeded) { '--help' }\n          if ($compatibilityHelpSucceeded) { '-?' }\n        ) -join ', '\n      }\n    }\n  }\n\n  return $null\n}\n\n$modernSqlcmd = Find-CompatibleGoSqlcmd -RequiredFlags @('-E', '-G', '-U')\n```\n\nIf no candidate passes and the migration workflow's preparation consent covers a\nCurrentUser tool install, run the official Windows package command without another\nprompt. Otherwise ask once for approval. Refresh the current process `PATH`, and\nvalidate again:\n\n```powershell\nwinget install sqlcmd --accept-package-agreements --accept-source-agreements\nif ($LASTEXITCODE -ne 0) {\n  throw 'Modern sqlcmd installation failed.'\n}\n\n$refreshedPathSegments = @(\n  $env:Path\n  [Environment]::GetEnvironmentVariable('Path', 'Machine')\n  [Environment]::GetEnvironmentVariable('Path', 'User')\n) | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }\n$env:Path = $refreshedPathSegments -join ';'\n$modernSqlcmd = Find-CompatibleGoSqlcmd -RequiredFlags @('-E', '-G', '-U')\nif (-not $modernSqlcmd) {\n  throw 'Modern sqlcmd was installed but could not be validated. Open a new terminal and retry.'\n}\n```\n\nIf installation is declined, `winget` is unavailable, or validation still fails,\nstop before connecting and provide\n`https:\u002F\u002Flearn.microsoft.com\u002Fsql\u002Ftools\u002Fsqlcmd\u002Fsqlcmd-download-install`. Never run\nan unqualified `sqlcmd`; invoke `$modernSqlcmd.Path` so an older executable earlier\non `PATH` cannot be selected accidentally.\n\nCreate access-controlled local `.sql` files for the read-only query batches and\nseparate source and target output files. Query files must not contain credentials,\ntokens, connection strings, DDL, DML, DBCC, or `:!!` shell commands. Put both\ntarget passes in one query file and one `sqlcmd` process so attended Entra\nauthentication occurs at most once when the reusable target connection and cached\ntoken adapter are unavailable. Bracket that target process with the two\nnoninteractive Windows-authenticated source passes:\n\nThe following direct-source process applies only while the original source is\nqueryable. If the handoff marks it `RESTORING`, do not execute either source\nprocess. Instead, validate the evidence package hash and cutoff binding and use\nits normalized inventory\u002Fcount records as source passes, or run both source\npasses against the separately restored cutoff copy. Before using these fallback\nprocesses, try the handoff's reusable source connection and token-capable route.\nFor an Entra fallback, silently reuse the cached authentication context and allow\nat most one attended sign-in across both source passes.\n\n```powershell\n$sourceAuthenticationArguments = @(switch ($sourceAuthentication) {\n  'Windows' {\n    @('-E')\n    break\n  }\n  'Entra' {\n    if ([string]::IsNullOrWhiteSpace($sourceUserPrincipalName)) {\n      throw 'The Entra source handoff does not contain a user principal name for attended fallback.'\n    }\n    @('-G', '-U', $sourceUserPrincipalName)\n    break\n  }\n  default {\n    throw \"Unsupported source authentication mode '$sourceAuthentication'.\"\n  }\n})\n\n& $modernSqlcmd.Path -S $sourceServer -d $sourceDatabase `\n  @sourceAuthenticationArguments -b -r1 -h -1 -W -s '|' -w 65535 `\n  -i $sourcePassAQueryPath -o $sourcePassAOutputPath\nif ($LASTEXITCODE -ne 0) {\n  throw \"Source validation pass A failed with exit code $LASTEXITCODE.\"\n}\n\n$targetAuthenticationArguments = @(switch ($targetAuthentication) {\n  'Windows' {\n    if ($targetType -ne 'SQL VM') {\n      throw 'Windows target authentication is supported only for a SQL VM handoff.'\n    }\n    @('-E')\n    break\n  }\n  'Entra' {\n    if ([string]::IsNullOrWhiteSpace($targetUserPrincipalName)) {\n      throw 'The Entra target handoff does not contain a user principal name for attended fallback.'\n    }\n    @('-G', '-U', $targetUserPrincipalName)\n    break\n  }\n  default {\n    throw \"Unsupported target authentication mode '$targetAuthentication'.\"\n  }\n})\n\n& $modernSqlcmd.Path -S $targetServer -d $targetDatabase `\n  @targetAuthenticationArguments -b -r1 -h -1 -W -s '|' -w 65535 `\n  -i $targetPassesQueryPath -o $targetPassesOutputPath\nif ($LASTEXITCODE -ne 0) {\n  throw \"Target validation passes failed with exit code $LASTEXITCODE.\"\n}\n\n& $modernSqlcmd.Path -S $sourceServer -d $sourceDatabase `\n  @sourceAuthenticationArguments -b -r1 -h -1 -W -s '|' -w 65535 `\n  -i $sourcePassBQueryPath -o $sourcePassBOutputPath\nif ($LASTEXITCODE -ne 0) {\n  throw \"Source validation pass B failed with exit code $LASTEXITCODE.\"\n}\n```\n\nUse `-C` only when trusting the presented server certificate is an explicitly\naccepted environment policy. Otherwise configure a verifiable certificate and\nomit `-C`. Treat a nonzero `sqlcmd` exit code, missing output, malformed result, or\ninteractive-login cancellation as `Fail`. Normalize and compare the structured\nsource and target result sets in memory; never infer a match from console text or\na zero exit code alone.\n\nUse strict pipe-delimited rows for every validation result. Do not use `FOR JSON`,\n`FOR XML`, formatted tables, or a split limit. Prefix each row with one of the\ndeclared record types (`META`, `INVENTORY`, `COUNT`, `ERROR`, or `CUTOFF`), run\n`SET NOCOUNT ON`, split on every `|`, and require the exact field count for that\nrecord type. Encode nullable text as `~` for `NULL`, otherwise prefix it with\n`v:` and replace `%`, `|`, CR, and LF with `%25`, `%7C`, `%0D`, and `%0A`\nrespectively. Decode in reverse replacement order with `%25` last. Convert\n`COUNT_BIG`, compatibility levels, isolation levels, and Boolean values to their\ndeclared PowerShell types; malformed, duplicate, missing, or unknown rows fail\nvalidation.\n\nSelect the database only with the `sqlcmd -d` argument. Do not put `USE` in a\nmachine-read query batch because its context message can contaminate delimited\noutput. Capture `$LASTEXITCODE` immediately after each `sqlcmd` process, before\nACL updates, output parsing, or any other native command.\n\nWhen constructing the one target file containing passes A and B, terminate each\npass and place `GO` on its own line. Join generated fragments with an explicit\nnewline; never concatenate strings in a way that can produce `GOSET`:\n\n```powershell-pseudocode\n$targetPassesSql = @(\n  (New-ValidationPass -Pass 'A').TrimEnd()\n  'GO'\n  (New-ValidationPass -Pass 'B').TrimEnd()\n  'GO'\n) -join [Environment]::NewLine\n```\n\n## Status model\n\nEvery validation scenario has one of these statuses:\n\n- `In progress`: started but not yet conclusively completed.\n- `Pass`: completed and matched, or an approved exception matched its expectation.\n- `Inconclusive`: the check completed, but a writable source changed or differs\n  from the target and no cutoff-consistent source reference exists to distinguish\n  expected post-cutoff activity from a migration difference.\n- `Fail`: proven mismatch, query failure, source change in `Quiesced` mode,\n  unexpected target change, unsupported required check, or missing required\n  evidence.\n\nThe database result is `Pass` only when every required scenario passes and the\ncomparison boundary is proven. It is `Ready with conditions` when every measured\nscenario is `Pass` or `Inconclusive`, no scenario failed, and a writable source\nprevents exact point-in-time equality from being proven. It remains `In progress`\nwhile a required scenario is running and is `Fail` when any required scenario\nfails. Do not turn a proven cutoff mismatch, missing target table, or query failure\ninto `Ready with conditions`.\n\n## Workflow\n\n```text\nPhase 0  Accept the handoff and prove read-only access without reconfirmation\nPhase 1  Compare the complete user-table inventory\nPhase 2  Capture exact source and target row-count pass A\nPhase 3  Recapture exact target and source row-count pass B\nPhase 4  Run schema\u002Fcontent checks only for the explicit Full profile\nPhase 5  Classify stability and cutoff evidence, then publish one report\n```\n\nThe `RowCount` profile runs Phases 0-3 and 5. It does not ask whether to run Phase\n4. The `Full` profile runs all phases. Prefer the inherited target connection for\nall target-side checks. On fallback, use one target `sqlcmd` process for both\ntarget passes so interactive authentication is not repeated per table or phase.\n\n## Phase 0 - Handoff and safety gates\n\n1. Load the source-target mapping and target type from the immutable migration\n  manifest without asking the user to confirm them again.\n2. Resolve and validate modern `sqlcmd`, reusing the migration workflow's tool\n  installation consent when it is absent; otherwise ask once.\n3. Test and reuse the inherited source and target connections independently. For\n  an Entra source, try its inherited token-capable route silently before using\n  the approved `-G -U \u003Csource-user-principal-name>` fallback, with at most one\n  attended source sign-in for the run. For a Windows source, use `-E` only when\n  its inherited handle is unavailable. If the target connection is unavailable, try the\n  cached Microsoft Entra token context silently for an Entra handoff. Use\n  `-G -U \u003Cuser-principal-name>` once only when both Entra routes fail. For a\n  Windows-authenticated SQL VM handoff, retain that mode and use `-E` when the\n  inherited target handle is unavailable. Do not infer source authentication\n  from an on-premises location or silently switch either endpoint's identity.\n  Verify the actual server and database identity returned by each endpoint.\n4. Verify the target database is online and queryable.\n5. Determine the comparison mode from the migration handoff. For `Quiesced`,\n  confirm the source remains quiesced. For `Writable source with cutoff`, verify\n  the final backup file, completion time, and LSN from the immutable manifest;\n  use a hash-verified immutable source evidence package captured while quiesced or\n  a separately restored copy at that exact LSN. When the original source is\n  `RESTORING`, do not connect to it. Reject a missing, mismatched, or incomplete\n  cutoff reference rather than degrading to current-source observation.\n6. Verify the principal can read catalog metadata and `SELECT` every in-scope user\n   table. Insufficient visibility is a failure, not a zero count.\n7. Create the in-memory scenario manifest with all checks set to `In progress` and\n  proceed automatically. Do not ask for permission to execute read-only queries.\n\nDo not impersonate a broader principal or grant permissions as part of validation.\n\n## Phase 1 - Inventory and baseline fingerprints\n\nOn both endpoints, capture before-values without changing either database:\n\n- Actual server, database, engine edition, database state, collation, and\n  compatibility level where exposed by the target.\n- Maximum `modify_date` for user objects and the count of user objects.\n- A deterministic hash of the normalized user-object inventory and schema metadata\n  collected in Phase 2.\n- Per-table row counts collected in Phase 3, timestamped in UTC.\n- Source quiescence evidence or writable-source cutoff file\u002Ftime\u002FLSN from the\n  migration handoff.\n\nFor `RowCount`, compare the complete normalized `(schema, table)` inventory before\ncounting. A source table missing on target or an unexpected target table is a\n`Fail`, unless it exactly matches an inherited approved exception. This inventory\ngate prevents a row-count run from silently skipping a missing table. Full column,\nconstraint, module, and permission comparison belongs to the `Full` profile.\n\nA catalog `modify_date` does not detect data changes, so row counts and optional\ncontent signatures must also be recaptured in Phase 5. Record isolation level and\nwhether source quiescence was independently confirmed. Do not change isolation or\ndatabase options to improve consistency.\n\n## Phase 2 - Object and schema comparison\n\nFor `RowCount`, execute only the user-table inventory subset described in Phase 1\nand continue directly to Phase 3. Do not ask whether to run the remaining checks.\nFor `Full`, compare the complete schema below.\n\nCompare source and target counts and detailed inventories by schema and object\nname for all supported user objects:\n\n- schemas, tables, views, stored procedures, scalar\u002Ftable functions, synonyms,\n  sequences, and user-defined types;\n- columns, data types, lengths, precision, scale, nullability, collation, identity,\n  computed-column definitions, and defaults;\n- primary keys, unique\u002Fcheck\u002Fdefault constraints, foreign keys and referential\n  actions;\n- indexes and indexed columns, including uniqueness, filters, and disabled state;\n- triggers, temporal-table metadata, and partition metadata;\n- database users, roles, role membership, and explicit database permissions when\n  they are in migration scope.\n\nIgnore Microsoft-shipped objects. Compare normalized module definitions when the\nprincipal has metadata visibility. If a definition is encrypted or unavailable,\nreport that object as failed unless it is an approved exception. Account for\nplatform differences only through the approved exception list, especially SQL\nAgent and server-scoped objects that do not exist in Azure SQL Database.\n\nFor every mismatch, record the scenario, source object name, target object name,\nsource value, target value, and a concise reason such as `Missing on target`,\n`Unexpected on target`, or `Column precision differs`.\n\n## Phase 3 - Exact row-count comparison\n\nCompare an exact `COUNT_BIG(*)` for every in-scope user table on source and target.\nCatalog partition row estimates may be used to plan the run, but never as pass\nevidence. Generate table-specific statements only from catalog values returned by\nthe approved database and quote every identifier with `QUOTENAME`; never\ninterpolate an unvalidated identifier into a local query file.\n\nProcess tables in deterministic schema\u002Fname order. Generate one read-only batch per\nendpoint pass and return structured rows containing database, schema, table,\n`COUNT_BIG`, pass identifier, and UTC query timestamps. Never parse formatted table\noutput. A timeout, permission error, unsupported object, duplicate\u002Fmissing output\nrow, or interrupted query is a `Fail` for that table, not `0` and not `Pass`. Retry\none transient connection failure with the same authenticated session; do not prompt\nper table or silently reduce scope.\n\nUse `QUOTENAME` for every catalog-derived identifier and isolate each dynamic\n`COUNT_BIG(*)` in `TRY\u002FCATCH` so one table error is recorded and later tables still\nrun. Do not use `NOLOCK`, `READ UNCOMMITTED`, partition metadata, or approximate\ncounts as equality evidence. Do not introduce stronger isolation that blocks source\nwrites. Record that two equal count passes cannot detect same-count row updates.\n\nWhen the original source is queryable, run the passes in this order:\n\n1. Source pass A.\n2. Target pass A.\n3. Target pass B.\n4. Source pass B.\n\nWhen it is `RESTORING`, substitute the verified immutable evidence package's two\nsource passes, or execute source passes A and B against the separately restored\ncutoff copy. Validate that the reference names the same database, final file,\ncompletion time, and final LSN as the handoff before comparing any target count.\n\nThis brackets the target observations with source observations and detects changes\nduring the validation window. Use a cutoff reference automatically when the\nmigration handoff contains either a queryable validation copy restored through the\nfinal backup LSN or table counts captured from a transactionally consistent source\nsnapshot at that cutoff. Do not ask the user to create such a reference during\npost-migration validation.\n\nClassify each mapped table as follows:\n\n| Evidence | Result |\n| --- | --- |\n| Target A differs from target B | `Fail`: target changed during validation |\n| Quiesced or cutoff reference is stable and differs from target | `Fail`: proven mismatch |\n| Quiesced or cutoff reference is stable and equals target | `Pass` |\n| Writable source, no cutoff reference, source A equals source B and target equals that value | `Pass` observed; database remains `Ready with conditions` |\n| Writable source, no cutoff reference, source changed or its stable current count differs from target | `Inconclusive`: possible post-cutoff divergence |\n| Any required count is unavailable or malformed | `Fail`: validation did not complete |\n\nNever infer cutoff equality from current writable-source counts. Current source\ncounts are evidence of observed state only. A row-count match proves quantity, not\nrow content; state that limitation instead of upgrading it to full data equality.\n\nFor each table report:\n\n| Field | Value |\n| --- | --- |\n| Scenario | `Exact row count` |\n| Object | `\u003Cschema>.\u003Ctable>` |\n| Source pass A \u002F B | `\u003CCOUNT_BIG result>` \u002F `\u003CCOUNT_BIG result>` |\n| Target pass A \u002F B | `\u003CCOUNT_BIG result>` \u002F `\u003CCOUNT_BIG result>` |\n| Cutoff reference | `\u003CCOUNT_BIG result>`, `Not available`, or `Not applicable` |\n| Status | `Pass`, `Inconclusive`, `Fail`, or `In progress` |\n| Reason | Empty on pass; concise instability, limitation, mismatch, or error otherwise |\n\nA matching row count proves quantity, not content. Continue with Phase 4.\n\n## Phase 4 - Full-profile read-only checks\n\nSkip this phase automatically for `RowCount`. For an explicitly requested `Full`\nprofile, run these additional read-only checks without asking for individual\napproval:\n\n- Compare identity current values, sequence current values, temporal-table row\n  counts, and min\u002Fmax temporal periods where applicable.\n- Compare null counts, minimum, maximum, and deterministic aggregates for approved\n  critical columns where data types support them.\n- For critical tables with a stable primary\u002Funique key, compare deterministic\n  key-range chunks using an approved content-hash implementation. Canonicalize\n  nulls, binary values, date\u002Ftime precision, collation-sensitive text, and numeric\n  representation identically on both sides. Record the algorithm and chunk ranges.\n- Run approved read-only application smoke queries. Writes and transaction tests\n  belong to cutover testing and are outside this read-only skill.\n\nDo not use `CHECKSUM_AGG(BINARY_CHECKSUM(*))` as sole proof of equality because\ncollisions and unsupported types can hide differences. Content checks supplement,\nbut do not replace, exact row counts and schema comparison.\n\n## Phase 5 - Change detection and report\n\nUse the A\u002FB results already captured in Phases 2 and 3. For `Full`, also compare\nthe content signatures captured by that profile:\n\n- If this workflow issued any mutating statement, stop and report a safety failure.\n- In `Quiesced` mode, if source schema, source row counts, or source content\n  signatures changed, fail affected consistency scenarios with reason\n  `Source changed during validation`.\n- In `Writable source with cutoff` mode, compare the target with a valid cutoff\n  reference when one exists. Without one, classify changed or differing current\n  source counts as `Inconclusive`, not `Fail`, because current source state is not\n  the migration boundary. Return `Ready with conditions` when there are no failures.\n  An invalid cutoff manifest\u002Fchain or a proven cutoff mismatch is `Fail`.\n- If target schema, target row counts, or target content signatures changed, fail\n  affected scenarios with reason `Target changed during validation`.\n- A metadata timestamp change without a normalized schema difference is still\n  reported for review but does not by itself prove a schema change.\n\nThis skill guarantees that its own workflow is read-only. It detects covered\nexternal changes during the validation window; it cannot guarantee that unmeasured\ncontent did not change when full content signatures were not approved.\n\n## Result presentation\n\nKeep the complete failure list in the in-memory validation result and approved\nevidence report. In chat, display at most 10 failed objects at a time in stable\nscenario, database, schema, and object-name order.\n\nWhen more than 10 failures exist:\n\n- Show `Failures 1-10 of \u003Ctotal>` and the report location.\n- Do not open a `Next` prompt. The complete stable result set remains in the report.\n- Include `Inconclusive` tables in a separate summary and report section; do not\n  present them as migration failures.\n\n## Result format\n\nProduce a sanitized Markdown report and, when requested, a machine-readable JSON\nreport. Never include credentials or secret-bearing connection properties.\n\n```markdown\n# Post-migration data validation report\n\n- Source: \u003Csanitized server\u002Fdatabase>\n- Target: \u003Ctarget type and sanitized server\u002Fdatabase>\n- Validation profile: \u003CRowCount | Full>\n- Validation window: \u003CUTC start> to \u003CUTC finish>\n- Overall status: \u003CPass | Ready with conditions | Fail | In progress>\n- Comparison mode: \u003CQuiesced | Writable source with cutoff>\n- Migration cutoff: \u003Cfinal backup UTC completion time, LSN, and file | Not applicable>\n- Source unchanged during validation: \u003CYes | No | Not fully proven>\n- Target unchanged during validation: \u003CYes | No | Not fully proven>\n\n| Validation scenario | Status | Passed | Inconclusive | Failed | In progress | Notes |\n| --- | --- | ---: | ---: | ---: | ---: | --- |\n| Object inventory | \u003Cstatus> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Csummary> |\n| Schema definitions | \u003Cstatus or Not run> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Csummary> |\n| Exact row counts | \u003Cstatus> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Csummary> |\n| Critical data content | \u003Cstatus or Not run> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Csummary> |\n| Change detection | \u003Cstatus> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Cn> | \u003Csummary> |\n\n## Failed objects\n\n| # | Scenario | Object | Status | Reason |\n| ---: | --- | --- | --- | --- |\n| 1 | \u003Cscenario> | \u003Cdatabase.schema.object> | Fail | \u003Creason> |\n```\n\nFor `RowCount`, state prominently that exact table counts were compared but row\ncontent and complete schema equality were not validated. Include all A\u002FB counts\nand query timestamps in the machine-readable or evidence report even when chat\nshows only the summary.\n\nInclude approved exceptions, checks not fully proven, query timestamps, isolation,\nquiescence or cutoff evidence, expected post-cutoff divergence, content-hash\nalgorithms and ranges, and the report\u002Fevidence\nlocation. A failure row must always identify the object when one exists and explain\nthe reason. For database-level failures, use the database name as the object.\n",{"name":5,"description":7},"main","d2b16500cb10bf44117390e08717ca731032d423","corenote\u002Fmigration\u002Fskills\u002Fvalidate-post-migration-data",0,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsqlcon-eu-2026-demos","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-11-01 23:31:12",{"source":8,"skillName":5,"commands":50,"prompt":60,"zipAvailable":61},[51,54,57],{"tool":52,"command":53},"npx","npx skills add microsoft\u002Fsqlcon-eu-2026-demos --skill validate-post-migration-data",{"tool":55,"command":56},"bunx","bunx skills add microsoft\u002Fsqlcon-eu-2026-demos --skill validate-post-migration-data",{"tool":58,"command":59},"pnpm","pnpm dlx skills add microsoft\u002Fsqlcon-eu-2026-demos --skill validate-post-migration-data","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsqlcon-eu-2026-demos\u002Fblob\u002Fmain\u002Fcorenote\u002Fmigration\u002Fskills\u002Fvalidate-post-migration-data\u002FSKILL.md",true,[63,69,73],{"path":64,"resourceType":65,"resourceTypeDesc":66,"sizeBytes":67,"sourceHtmlUrl":68},"references\u002Findex.md","REFERENCE","参考文档",91,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Flvgl-9-4\u002Freferences\u002Findex.md",{"path":70,"resourceType":65,"resourceTypeDesc":66,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Fother.md",631,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Flvgl-9-4\u002Freferences\u002Fother.md",{"path":74,"resourceType":65,"resourceTypeDesc":66,"sizeBytes":75,"sourceHtmlUrl":76},"skill-contract.yml",3192,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsqlcon-eu-2026-demos\u002Fblob\u002Fmain\u002Fcorenote\u002Fmigration\u002Fskills\u002Fvalidate-post-migration-data\u002Fskill-contract.yml",[78,88,98,109,120,129],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":85,"publishedAt":35},"01M69AGTKN8F66BXE45KQ3MDMX","keynote-demo-app","Build or extend a SQLCon EU 2026 keynote demo application so it looks and behaves like the other keynote apps. Use when creating a new demo view (invoices, operations, orders), restyling an existing app to match, adding a deliberate database anti-pattern for a troubleshooting demo, or wiring an app to Azure SQL or Fabric SQL with managed identity. Triggers include \"make this look like the keynote app\", \"build a demo view\", \"add the slow query demo\", \"match Caldova styling\".","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsqlcon-eu-2026-demos\u002Fblob\u002Fmain\u002Fshared\u002FSKILL.md",[84],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[86,87,31,33],"keynote demo app","identity",{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":96,"publishedAt":35},"01M69AGNG0HQK50EW1CNEFTR1N","sql-server-to-sql-mi-lrs-migration","Migrate SQL Server databases to Azure SQL Managed Instance with Log Replay Service (LRS) using managed identity for Blob access. Use for SQL Server to SQL MI, LRS, log replay, continuous restore, or low-downtime backup-chain migrations.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsqlcon-eu-2026-demos\u002Fblob\u002Fmain\u002Fcorenote\u002Fmigration\u002Fskills\u002Fsql-server-to-sql-mi-lrs-migration\u002FSKILL.md",[94,95],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},[33,34,97,31,87],"sql server to sql mi lrs migration",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":106,"publishedAt":35},"01M69AGJC50G0YX7VQ52SQ0AD0","sql-bacpac-to-azure-sql-db-migration","Migrate one or all user databases from SQL Server to Azure SQL Database with an offline BACPAC workflow. Use for BACPAC, SqlPackage export\u002Fimport, bulk database migration, or offline Azure SQL Database migration requests.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsqlcon-eu-2026-demos\u002Fblob\u002Fmain\u002Fcorenote\u002Fmigration\u002Fskills\u002Fsql-bacpac-to-azure-sql-db-migration\u002FSKILL.md",[104,105],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},[33,107,31,108,34,32],"sql bacpac to azure sql db migration","workflow",{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":117,"publishedAt":35},"01M69AGFTTX13PCFKM3YVHKGDV","sql-backup-restore-to-azure-sql-vm-migration","Migrate a SQL Server 2008 through SQL Server 2025 source to a SQL Server 2025 target wherever it runs, including SQL Server on Azure VM, by creating a local full backup, uploading it to Azure Blob Storage with AzCopy and the operator's Microsoft Entra identity, and restoring from URL with the target SQL Server managed identity. Sources newer than SQL Server 2025 are blocked because target restore compatibility has not been validated. Use for SQL-to-SQL, local-backup, AzCopy, managed-identity, Azure SQL VM, or SQL Server 2025 restore migrations.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsqlcon-eu-2026-demos\u002Fblob\u002Fmain\u002Fcorenote\u002Fmigration\u002Fskills\u002Fsql-backup-restore-to-azure-sql-vm-migration\u002FSKILL.md",[115,116],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},[118,33,31,34,87,9,119],"sql backup restore to azure sql vm migration","storage",{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":127,"publishedAt":35},"01M69AGDP6XXM1YW7X1VV1QKE5","run-migration-assessment","Route generic or unresolved SQL Server assessment, readiness, compatibility, cost, and SKU recommendation requests. Use for bare server names or whenever Azure versus local\u002Fon-premises is not explicit; ask which source applies, then delegate.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsqlcon-eu-2026-demos\u002Fblob\u002Fmain\u002Fcorenote\u002Fmigration\u002Fskills\u002Frun-migration-assessment\u002FSKILL.md",[126],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[128,34,33],"run migration assessment",{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":135,"publishedAt":35},"01M69AGBJN9ESKFXD8YXB7J20W","recommend-sku-sizing","Collect performance data and calculate Azure SQL SKU recommendations only after the source is explicitly confirmed local\u002Fon-premises. Never use for a generic SKU request or bare server name; route unresolved requests through run-migration-assessment.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fsqlcon-eu-2026-demos\u002Fblob\u002Fmain\u002Fcorenote\u002Fmigration\u002Fskills\u002Frecommend-sku-sizing\u002FSKILL.md",[],[136,137,33,31],"recommend sku sizing","performance"]