Skip to content

Commit 8d13971

Browse files
authored
Update TOP(100) recommendation
1 parent 4200004 commit 8d13971

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

SQL Server Name Convention and T-SQL Programming Style.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ SQL Server T-SQL Coding Conventions, Best Practices, and Programming Guidelines.
402402
DECLARE @n int = 1;
403403
SELECT TOP@n name FROM sys.objects;
404404
```
405-
- For demo queries use `TOP(100)` or lower value because SQL Server uses one sorting method for `TOP` 1-100 rows, and a different one for 101+ rows.
406-
More details [here](https://www.brentozar.com/archive/2017/09/much-can-one-row-change-query-plan-part-2/).
405+
- <a id="top100"></a>For demo queries use `TOP(100)` or lower value because SQL Server uses one sorting method for `TOP` 1-100 rows, and a different one for 101+ rows.
406+
More details [here](https://www.brentozar.com/archive/2017/09/much-can-one-row-change-query-plan-part-2/) and [here](https://sqlsunday.com/2020/12/08/the-curious-case-of-the-top-n-sort/).
407407
- Avoid specifying integers in the `ORDER BY` clause as positional representations of the columns in the select list.
408408
The statement with integers is not as easily understood by others compared with specifying the actual column name.
409409
In addition, changes to the select list, such as changing the column order or adding new columns, requires modifying the `ORDER BY` clause in order to avoid unexpected results.

0 commit comments

Comments
 (0)