sndev.io / docs

export-records

Export rows from any table to XML, CSV, or Table-API JSON.

The export-records command dumps rows from a single table to a local file. Pick the format that matches the downstream consumer: xml_unload for re-import into another ServiceNow instance, csv for spreadsheet analysis, json for cursor-paginated Table-API JSON (no 10K limit). For XML/CSV, exports above ~10K rows are automatically partitioned by sys_id prefix so no rows are silently dropped.

sn export-records <table> "<query>" <path> [--format xml_unload|csv|json] [--partition-prefix-len 1|2|3] [--auto-partition|--no-auto-partition] [--limit N] [--progress] [--target <name>] [--profile <name>]

Export rows from a table to XML, CSV, or Table-API JSON.

Arguments

NameRequiredDescription
tableYesServiceNow table name (e.g. incident, sys_dictionary).
queryYesEncoded query. Pass "" to export all rows.
pathYesOutput file path.

Flags

FlagDefaultDescription
--format <fmt>xml_unloadOutput format: `xml_unload` (default), `csv`, or `json` (Table API).
--auto-partitionXML/CSV only. Force partitioned export.
--no-auto-partitionXML/CSV only. Force single-shot export (silently truncates at 10K rows — not recommended for large tables).
--partition-prefix-len <n>2XML/CSV only. `1` (16 partitions), `2` (256), or `3` (4096).
--limit <n>XML/CSV single-shot only. Optional row cap.
--progressShow per-partition / per-page progress.
--target <name>Select an instance from the registry (default: current default).
--profile <name>Credential profile under `--target`.

Examples

sn export-records incident "active=true" /tmp/open-incidents.xml
✓ Exported 1,284 incident row(s) — 6,412,800 bytes → /tmp/open-incidents.xml
sn export-records sys_dictionary "" /tmp/dict.csv --format csv --progress
[partition 00..] 2,104 rows
[partition 01..] 2,037 rows
...
✓ Exported 89,412 sys_dictionary row(s) — 42,110,982 bytes → /tmp/dict.csv [256 partitions]
sn export-records sys_script_include "" /tmp/si.json --format json
✓ Dumped 312 sys_script_include record(s) — 1,204,812 bytes → /tmp/si.json

Single-table only. Related lists (variables for catalog items, journals for incidents, group memberships for users) are not included. For full artifact graphs use sn export-update-set.