nav2009-db-maintenancelisted
Install: claude install-skill whobat/AI-Agent-skills
# NAV 2009 DB Maintenance
> Targets the **SQL Server database behind a Dynamics NAV 2009 install**. The bundled script
> `scripts/Invoke-NavDbMaintenance.ps1` **plans maintenance and (only with `-Execute`) runs it**,
> emitting JSON throughout. **Default mode is a DRY RUN** — the script prints the exact T-SQL it
> would execute and changes nothing without `-Execute`. It only rebuilds/reorganizes and updates
> statistics on existing indexes; it **NEVER creates or drops indexes** (NAV owns them). It never
> calls an LLM.
>
> Before running maintenance, diagnose the state first with **nav2009-sql-performance** (fragmentation,
> stale stats, SIFT sizes). Then plan an action here and confirm the T-SQL before executing.
`SCRIPT` = this skill's `scripts/Invoke-NavDbMaintenance.ps1`. Requires **PowerShell 7+** (`pwsh`)
and network access to the SQL Server.
## Permissions & auth
- Default is **Windows integrated auth** (the user running `pwsh`). Pass `-SqlCredential` for SQL
auth — it is a `PSCredential`; let PowerShell prompt (`-SqlCredential (Get-Credential)`). Never
put a password on the command line.
- Required permissions by action:
- **backup** — `db_backupoperator` (or `db_owner`)
- **index_maintenance** — `db_owner` or `ALTER` permission on the indexes
- **checkdb** — `db_owner` or `sysadmin`
- **statistics** — `db_owner` or `UPDATE STATISTICS` permission
- Connections are unencrypted by default (NAV 2009-era instances rarely have TLS certs); add
`-Encrypt` i