-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path101_rows_problem.sql
More file actions
38 lines (29 loc) · 1.2 KB
/
101_rows_problem.sql
File metadata and controls
38 lines (29 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
Description
Demonstrate 101 rows problem on SQL Server.
Recommendation
In SSMS: Change "Value for Select Top <n> Rows command" to 100 or less.
Tools > Options
SQL Server Object Explorer > Commands
Table and View Options > Value for Select Top <n> Rows command
*/
USE [AdventureWorks];
GO
SET STATISTICS TIME, IO ON;
GO
SELECT TOP (100) *
FROM [Sales].[SalesOrderDetail]
SELECT TOP (101) *
FROM [Sales].[SalesOrderDetail]
SET STATISTICS TIME, IO OFF;
GO
/* Execution Times
(100 rows affected)
Table 'SalesOrderDetail'. Scan count 1, logical reads 7, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
(101 rows affected)
Table 'SalesOrderDetail'. Scan count 1, logical reads 7, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 50 ms.
*/