我們的品牌

Impact-Company-Logo-English Black-01-177x54

歡迎造訪施耐德電機全球網站

歡迎訪問我們的網站
		
我们今天能为您提供什么帮助?
SQL query resulted in error: Exception of type 'System.OutOfMemoryException' was thrown

Issue
Executing SQL query in Microsoft SQL Server Management Studio (SSMS) that returns a large amount of data may result in the following error:
An error occurred while executing the batch. The error message is: Exception of type 'System.OutOfMemoryException' was thrown

Product Line
SQL Server Management Studios

Environment
SQL Server

Cause
This issue occurs because SSMS has insufficient memory to allocate for large results.
Microsoft SQL Server Management Studio (SSMS) is a 32-bit process. Therefore, it is limited to 2 GB of memory. SSMS imposes an artificial limit on how much text 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 'System.OutOfMemoryException'.

Resolution

Workaround: Try one of the following methods.

​Method 1: Output the results as text
Configure the query window to output the query results as text. A text output uses less memory than the grid, and it may be sufficient to display the query results. To make this change, follow these steps:
1. Right-click the query window.
2. Click Results to
3. Click Results to Text.

Screenshot of Options.

Method 2: Output the results to a file
1. Right-click the query window.
2. Click Results to.
3. Click Results To File.
4. Run the query, and then select the location to save the results file.

screenshot of results to file

Method 3: Use sqlcmd
Use the sqlcmd tool 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.

For more information on sqlcmd Utility use the following link: https://msdn.microsoft.com/en-us/library/ms162773.aspx

施耐德電機Taiwan

探索更多
系列:
探索更多
系列:
  • 產品文檔
  • 軟體下載
  • 產品選型工具
  • 產品替代和替換
  • 幫助和聯絡中心
  • 尋找我們的辦公室
  • 取得報價
  • 施耐德電機社群
  • 人才招募
  • 公司簡介
  • 舉報不當行為
  • 無障礙
  • 新聞中心
  • 投資者
  • 專業洞察
  • 台灣施耐德電機學院
  • 綠色影響力落差調查
  • Schneider Go Green 2025
  • 隱私政策
  • Cookie通告
  • 使用條款
  • Change your cookie settings