Skip to content

Commit 7657277

Browse files
authored
Update Title and cause with OOM message, also applies to SSMS not SQL Server
1 parent 998f0cd commit 7657277

1 file changed

Lines changed: 6 additions & 34 deletions

File tree

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: Exception when you execute a query
2+
title: OutOfMemoryException Exception when you execute a query
33
description: This article provides workarounds for the problem that occurs when you use SQL Server Management Studio (SSMS) to run a SQL query that returns a large amount of data.
4-
ms.date: 10/29/2020
4+
ms.date: 04/02/2025
55
ms.custom: sap:SQL Server Management, Query and Data Tools
66
---
7-
# Exception when you execute a query in SQL Server Management Studio
7+
# OutOfMemoryException Exception when you execute a query in SQL Server Management Studio (SSMS)
88

99
This article helps you resolve the problem that occurs when you use SQL Server Management Studio (SSMS) to run a SQL query that returns a large amount of data.
1010

@@ -13,16 +13,13 @@ _Original KB number:_   2874903
1313

1414
## Symptoms
1515

16-
When you use SSMS to run a SQL query that returns a large amount of data, you receive an error message that resembles the following:
16+
When you use SSMS to run a SQL query that returns a very large amount of data, you receive an error message that resembles the following:
1717

1818
> An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown
1919
2020
## Cause
2121

22-
This issue occurs because SSMS has insufficient memory to allocate for large results.
23-
24-
> [!NOTE]
25-
> SSMS is a 32-bit process. Therefore, it is limited to 2 GB of memory. SSMS imposes an artificial limit on how much text that can be displayed per database field in the results window. This limit is 64 KB in "Grid" mode and 8 KB in Text mode. If the result set is too large, the memory that is required to display the query results may surpass the 2 GB limit of the SSMS process. Therefore, a large result set can cause the error that is mentioned in the [Symptoms](#symptoms) section.
22+
This issue occurs because SSMS has insufficient memory to allocate for large results. SSMS is a 32-bit process. Therefore, it is limited to 2 GB of user-mode virtual memory. SSMS imposes an artificial limit on how much text that can be displayed per database field in the results window. This limit is 64 KB in "Grid" mode and 8 KB in Text mode. If the result set is too large, the memory that is required to display the query results may surpass the 2 GB limit of the SSMS process. Therefore, a large result set can cause the error that is mentioned in the [Symptoms](#symptoms) section.
2623

2724
## Workaround
2825

@@ -49,29 +46,4 @@ Configure the query window to output the query results to a file. A file output
4946

5047
Use [sqlcmd Utility](/sql/tools/sqlcmd-utility?redirectedfrom=MSDN&view=sql-server-ver15&preserve-view=true) instead of SSMS to run the SQL queries. This method enables queries to be run without the resources that are required by the SSMS UI. Additionally, you can use the 64-bit version of Sqlcmd.exe to avoid the memory restriction that affects the 32-bit SSMS process.
5148

52-
## Applies to
53-
54-
- SQL Server 2012 Express
55-
- SQL Server 2012 Developer
56-
- SQL Server 2012 Enterprise
57-
- SQL Server 2012 Standard
58-
- SQL Server 2012 Web
59-
- SQL Server 2008 R2 Datacenter
60-
- SQL Server 2008 R2 Developer
61-
- SQL Server 2008 R2 Enterprise
62-
- SQL Server 2008 R2 Express
63-
- SQL Server 2008 R2 Standard
64-
- SQL Server 2008 R2 Web
65-
- SQL Server 2008 R2 Workgroup
66-
- SQL Server 2008 Developer
67-
- SQL Server 2008 Enterprise
68-
- SQL Server 2008 Express
69-
- SQL Server 2008 Standard
70-
- SQL Server 2008 Web
71-
- SQL Server 2008 Workgroup
72-
- SQL Server 2005 Developer Edition
73-
- SQL Server 2005 Enterprise Edition
74-
- SQL Server 2005 Evaluation Edition
75-
- SQL Server 2005 Express Edition
76-
- SQL Server 2005 Standard Edition
77-
- SQL Server 2005 Workgroup Edition
49+

0 commit comments

Comments
 (0)