We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ErikEJ/SqlServer.Rules'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
SRP0023.md•929 B
# SQL Server Rule: SRP0023
| | |
|----|----|
| Assembly | SqlServer.Rules |
| Namespace | SqlServer.Rules.Performance |
| Class | UseExistenceInsteadOfCountRule |
## Rule Information
| | |
|----|----|
| Id | SRP0023 |
| Friendly Name | Enumerating for existence check |
| Category | Performance |
| Ignorable | true |
| Applicable Types | Procedure |
| | Scalar Function |
| | Table Valued Function |
## Description
When checking for existence use EXISTS instead of COUNT
## Summary
Consider using EXISTS instead of COUNT
### Examples
```sql
Create procedure dbo.ifExists
as
Set nocount on;
if(Select count(*) from dbo.TestTableSSDT)>1 begin
print 'Rows exist'
end
-- SRP0023
```
### Remarks
COUNT will iterate through every row in the table before returning the result whereas EXISTS
will stop as soon as records are found.
<sub><sup>Generated by a tool</sup></sub>