Troubleshooting Guide: Error 2375 — Aggregate Function Expects a Sequence Argument
Why This Error Happens
This error occurs when a T-SQL query attempts to pass a scalar expression, column reference, or non-sequence data type to an aggregate function (such as STRING_AGG, PERCENTILE_CONT, or newer SQL Server 2025 vector/sequence-based aggregates) that strictly requires an ordered sequence or array-type input. It is typically triggered by malformed query syntax, incorrect casting of a column to a scalar before aggregation, or a mismatch between the expected input type (sequence) and the actual argument type passed during query compilation. Less commonly, this can surface due to corrupted or outdated query plans cached from a previous SQL Server version during an upgrade to SQL Server 2025.
Step-by-Step Resolution Guide
Step 1: Identify the Offending Query and Function
- Check the SQL Server error log or SSMS output pane for the exact query batch that triggered Error 2375.
- Look specifically for aggregate functions like
STRING_AGG(),PERCENTILE_CONT(),PERCENTILE_DISC(), or new SQL Server 2025 sequence-aggregate functions. - Run the query in isolation using SQL Server Management Studio (SSMS) 21 or Azure Data Studio to reproduce the error outside of application context.
Step 2: Correct the Argument Type Passed to the Aggregate Function
- Ensure the argument passed is a valid sequence type (e.g., a column of array/table type, or a subquery returning an ordered row set), not a scalar variable or single expression.
- For
STRING_AGG, confirm the input expression resolves to a column, not a hardcoded scalar value:
SELECT STRING_AGG(ColumnName, ',') WITHIN GROUP (ORDER BY ColumnName)
FROM YourTable;
- If using SQL Server 2025’s new native vector/sequence aggregate functions, verify the input data type matches the expected
SEQUENCEorVECTORtype defined in the function signature usingsys.types.
Step 3: Clear and Rebuild the Query Plan Cache
- Open a new query window in SSMS connected to the affected instance.
- Run the following to clear potentially corrupted cached plans:
DBCC FREEPROCCACHE;
- Re-execute the original query to confirm the plan recompiles correctly against the current SQL Server 2025 engine.
Step 4: Update SQL Server 2025 Cumulative Update
- Navigate to Microsoft Update Catalog or use SQL Server Setup on Windows Server 2025 / Windows 11 to check for the latest Cumulative Update (CU).
- Apply the update via:
Control Panel > Programs > Microsoft SQL Server 2025 > Uninstall/Change > Check for Updates
- Restart the SQL Server service after installation:
Restart-Service -Name 'MSSQLSERVER'
Alternative or Verification Steps
- Verify the fix by re-running the original failing query and confirming it returns results without Error 2375; also check
sys.dm_exec_query_statsto confirm a new, valid execution plan has been cached. - If the error persists, isolate the aggregate function call into a simplified test script with sample static data to confirm whether the issue is data-driven (bad input) or a genuine compatibility bug requiring a Microsoft support case.