Troubleshooting Guide: Error 10744 — “The number of rows provided for a FETCH clause must be greater than zero”
Why This Error Happens
This error occurs when a T-SQL query uses the OFFSET...FETCH NEXT clause with a variable, parameter, or expression that evaluates to zero or a negative number. SQL Server 2025 strictly enforces that the FETCH NEXT row count must be a positive integer greater than zero, since a value of zero logically requests no rows, which is an invalid operation for this clause. This is most commonly caused by uninitialized variables, faulty pagination logic in application code, or a stored procedure receiving an unexpected @PageSize or @RowCount parameter of 0.
Step-by-Step Resolution Guide
Step 1: Identify the Offending Query
- Open SQL Server Management Studio (SSMS) and check the SQL Server Error Log via
Object Explorer > Management > SQL Server Logs. - Correlate the timestamp of Error 10744 with recent query activity using Extended Events or the
sys.dm_exec_query_statsDMV. - Look specifically for stored procedures or dynamic SQL containing
OFFSET @StartRow ROWS FETCH NEXT @PageSize ROWS ONLY.
Step 2: Validate Input Parameters in Application Code
- Check the application or API layer (e.g., C#, Java, or PowerShell scripts) that passes pagination values to SQL Server.
- Ensure
@PageSizeor equivalent variable is never set to0before being passed into the query; default it to a safe value like10or25if null. - Add a server-side guard clause in the stored procedure:
IF @PageSize <= 0 SET @PageSize = 10;
Step 3: Patch and Update SQL Server 2025
- Navigate to
Start > Settings > Windows Updateon Windows Server 2025 or Windows 11 and ensure the OS is fully patched. - Open SQL Server Configuration Manager and verify you are running the latest Cumulative Update (CU) for SQL Server 2025, as early builds had edge-case bugs validating
FETCH NEXTwith computed columns. - Restart the
MSSQLSERVERservice viaservices.mscafter applying any updates.
Step 4: Rewrite the Query Logic
- Modify the query to explicitly cast the row count variable:
FETCH NEXT (SELECT CASE WHEN @PageSize < 1 THEN 1 ELSE @PageSize END) ROWS ONLY. - Avoid using sub-queries or functions directly inside the
FETCH NEXTclause that might returnNULLor0unexpectedly; declare a local variable instead.
Alternative or Verification Steps
- Run the stored procedure manually in SSMS with a hardcoded value (e.g.,
EXEC GetData @PageSize = 5) to confirm the query executes without Error 10744. - If the error persists in a linked server scenario, check the compatibility level of the database via
sys.databasesand ensure it is set to160(SQL Server 2022) or higher to support currentFETCHsyntax validation.