---
title: "SQL-006: clsAppErrorCollection.RetrieveSQLCount"
summary: Counts filtered application error rows in App_Error.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-07-24
library: SAIF.Application.LogView
reference_type: package
---

# SQL-006: clsAppErrorCollection.RetrieveSQLCount

This query returns the total number of `App_Error` rows that match the same filter set used by [SQL-005](SQL-005-saif-application-logview.md). It allows callers to display total search counts even though the row query itself is limited to 300 results.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-006 |
| **Operation type** | Read |
| **Execution method** | Inline |
| **Database** | SQL Server |
| **Schema** | `[unqualified]` |
| **Command type** | Text |
| **Business object** | `clsAppErrorCollection` |
| **Criteria property** | `RetrieveSQLCount` |
| **Lifecycle method** | `BeforeRetrieve` (`DataRequest2`) |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `@ErrorDate` | Input | `DateTime` | N/A | Exact-date filter when a single error date is supplied instead of a range. |
| `@MachineName` | Input | `String` | 50 | Machine-name filter value. |
| `@Username` | Input | `String` | 50 | User-name filter value used for `LIKE` matching or paired with a generated `IN (...)` branch. |
| `@AppName` | Input | `String` | 50 | Application-name filter value. |
| `@SEARCHTEXT` | Input | `String` | 100 | Full-text predicate assembled by `GetSearchValue()`. |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [App_Error](../database-tables.md#app_error) | SELECT (count) | `Error_Date`, `Machine_Name`, `App_Name`, `User_Name`, `Error_Info`, `State_Info`, `Error_Source` |

## Sample SQL

```sql
SELECT Count(*)
FROM App_Error
WHERE cast(cast(App_Error.Error_Date as varchar(11))as datetime) = @ErrorDate
  and App_Error.Machine_Name = @MachineName
  and App_Error.App_Name = @AppName
  and App_Error.User_Name like @UserName
  AND CONTAINS((App_Error.Error_Info,App_Error.State_Info,App_Error.Error_Source),@SEARCHTEXT)
```

## Operations and processes
- [Search application error logs](../operations/error-search.md)
- [Normalize free-text search terms](../operations/error-search.md)

## Business rules
- [BR-001: Search results are capped at 300 rows](../business-rules.md#br-001-search-results-are-capped-at-300-rows)
- [BR-002: All sentinel suppresses selected filters](../business-rules.md#br-002-all-sentinel-suppresses-selected-filters)
- [BR-003: Semicolon-delimited filters expand to SQL IN lists](../business-rules.md#br-003-semicolon-delimited-filters-expand-to-sql-in-lists)
- [BR-004: Search text is normalized for full-text queries](../business-rules.md#br-004-search-text-is-normalized-for-full-text-queries)

## Sources
- `Application\SAIF.Application.LogView\clsAppErrorCollection.vb`

