Read table row count
This example demonstrates how to retrieve the total number of rows in a ServiceNow table
using the get_table_row_count endpoint.
The row count is calculated server-side using
sysparm_count=true, which is significantly faster and more efficient than
downloading records and counting them client-side.
You can optionally apply a server-side filter using the Query parameter
to count only matching rows (for example, high-priority incidents or active records).
-- Count ALL records in the Incident table
-- Uses server-side counting (no data rows are downloaded)
SELECT count
FROM get_table_row_count
WITH(
TableName='incident'
)
-- Count only HIGH PRIORITY incidents (priority = 1)
-- The Query parameter applies an encoded ServiceNow filter before counting
SELECT count
FROM get_table_row_count
WITH(
TableName='incident',
Query='priority=1'
)