Reference

Endpoint Get Table Row Count


Name

get_table_row_count

Description

Get table row count (count for all rows or for specified query filter) [API reference]

Parameters

Parameter Required Options
Name: TableName

Label: TableName

Table name
YES
Name: Query

Label: Query / Order By (Server Side Filter)

Server-side encoded query for filtering and ordering records. Supports string, numeric, date, NULL checks, AND/OR logic, and ORDER BY clauses.
Option Value
Equals (String) name=Test
Equals (Number) priority=1
Not Equal state!=closed
AND Condition state=active^priority=1
OR Condition state=active^ORstate=pending
IN List stateINactive,pending,closed
NOT IN List stateNOT INactive,closed
Starts With nameSTARTSWITHTest
Ends With nameENDSWITH001
Contains (LIKE) short_descriptionLIKEerror
Does Not Contain short_descriptionNOT LIKEpassword
Greater Than (Number) priority>2
Less Than (Number) priority<4
Between Numbers priority>=2^priority<=4
Is Empty assigned_toISEMPTY
Is Not Empty assigned_toISNOTEMPTY
Created After Date sys_created_on>=2026-01-01
Created Before Date sys_created_on<=2026-01-31 23:59:59
Created Today sys_created_on>=<>^sys_created_on<=<>
Updated Last 2 Days sys_updated_on>=<>
Multiple Conditions Mixed state=active^priority>1^short_descriptionLIKEerror
Order By Column ORDERBYname
Order By Column Desc ORDERBYDESCsys_created_on
Order By Multiple Columns ORDERBYpriority^ORDERBYDESCsys_created_on
Filter + Order state=active^ORDERBYsys_updated_on

Output Columns

Label Data Type (SSIS) Data Type (SQL) Length Description
count DT_I8 bigint
If the column you are looking for is missing, consider customizing ServiceNow Connector.

Input Columns

Label Data Type (SSIS) Data Type (SQL) Length Description
There are no Static columns defined for this endpoint. This endpoint detects columns dynamically at runtime.

Examples

SSIS

Use ServiceNow Connector in API Source or in API Destination SSIS Data Flow components to read or write data.

API Source

API Source - ServiceNow
Read and write ServiceNow data effortlessly. Integrate, manage, and automate incidents, tasks, attachments, and records — almost no coding required.
ServiceNow
Get Table Row Count
Required Parameters
TableName Fill-in the parameter...
Optional Parameters
Query / Order By (Server Side Filter)
SSIS API Source - Read from table or endpoint

API Destination

API Destination - ServiceNow
Read and write ServiceNow data effortlessly. Integrate, manage, and automate incidents, tasks, attachments, and records — almost no coding required.
ServiceNow
Get Table Row Count
Required Parameters
TableName Fill-in the parameter...
Optional Parameters
Query / Order By (Server Side Filter)
SSIS API Destination - Access table or endpoint

ODBC application

Use these SQL queries in your ODBC application data source:

Get Table Row Count Using Server-Side Filters

-- 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'
)

SQL Server

Use these SQL queries in SQL Server after you create a data source in Data Gateway:

Get Table Row Count Using Server-Side Filters

DECLARE @MyQuery NVARCHAR(MAX) = '-- 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''
)';

EXEC (@MyQuery) AT [LS_TO_SERVICENOW_IN_GATEWAY];