"System.OutOfMemoryException" exception when you execute a query in SQL Server Management Studio (转自MSDN)
Symptoms
When you use Microsoft SQL Server Management Studio (SSMS) to run an SQL query that returns a large amount of data, you receive an error message that resembles the following:
An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown
Cause
This issue occurs because SSMS has insufficient memory to allocate for large results.
Note 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" section.
Workaround
To work around this issue, 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:
- Right-click the query window.
- Click Results to.
- Click Results to Text.
Method 2: Output the results to a file
Configure the query window to output the query results to a file. A file output uses a minimal amount of memory. This reserves more memory for storing the results set. To make this change, follow these steps:
- Right-click the query window.
- Click Results to.
- Click Results To File.
- Run the query, and then select the location in which to save the results 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.
"System.OutOfMemoryException" exception when you execute a query in SQL Server Management Studio (转自MSDN)的更多相关文章
- Debugging a SQL Server query with WinDbg
Debugging a SQL Server query with WinDbg May 13, 2014 · Klaus Aschenbrenner · 5 Comments (Be sure to ...
- Exception of type 'System.OutOfMemoryException' was thrown
最近刚换了服务器,开始测试的时候未发现什么问题,可是一旦同一时间段操作的人比较多的时候,就会抛出如下错误: Server Error in '/' Application. Exception of ...
- 操作XmlDocument时,出现"System.OutOfMemoryException"异常,如何解决加载大数据的情况?
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.at System.St ...
- Dapper学习(一)之Execute和Query
Dapper是一个用于.NET的简单的对象映射,并且在速度上有着轻ORM之王的称号. Dapper扩展IDbConnection,提供有用的扩展方法来查询数据库. 那么Dapper是怎样工作的呢? 总 ...
- .Net 内存溢出(System.OutOfMemoryException)的常见情况和处理方式总结
.Net 内存溢出(System.OutOfMemoryException)的常见情况和处理方式总结 在什么情况下会出现OutOfMemonryException呢? 在我们试图新建一个对象时,而垃圾 ...
- .Net 内存溢出(System.OutOfMemoryException)
.Net 内存溢出(System.OutOfMemoryException) 在什么情况下会出现OutOfMemonryException呢? 在我们试图新建一个对象时,而垃圾收集器又找不到任何可用内 ...
- 内存溢出System.OutOfMemoryException
.Net 内存溢出(System.OutOfMemoryException)的常见情况和处理方式总结 在什么情况下会出现OutOfMemonryException呢? 在我们试图新建一个对象时,而垃圾 ...
- ASP.NET中出现内存溢出错误System.OutOfMemoryException
原因1:数据库服务器性能问题导致内存不够用,从而引起内存溢出 原因2:在IIS的应用程序池中进行配置,引起IIS服务器的内存分配问题,从而引起内存溢出 分析: 32位操作系统的寻址空间是 ...
- 引发类型为“System.OutOfMemoryException”的异常
在运维工作中,经常能接到客户的反馈这个:引发类型为“System.OutOfMemoryException”的异常.客户反馈物理内存都还有富余,怎么报内存不足的错误呢! 什么时候会引发System.O ...
随机推荐
- 浅尝Vue.js组件(一)
本篇目录: 组件名 组件注册 全局注册 基础组件的自动化全局注册 局部注册 在模块系统中局部注册 Prop 单向数据流 Prop验证 类型检查 非Prop特性 替换/合并已有的特性 禁用特性继承 自定 ...
- 理解Golang包导入
Golang使用包(package)这种语法元素来组织源码,所有语法可见性均定义在package这个级别,与Java .python等语言相比,这算不上什么创新,但与C传统的include相比,则是显 ...
- MVC返回文件
上一篇 介绍了Action 返回View, 顺便也看到了返回Json的处理, 这一篇并不看文件返回的源码, 此篇是为了应用. 1. Response返回文件 在MVC的项目中, 还是能看到很多同事, ...
- java设计模式-菜鸟网络
http://www.runoob.com/design-pattern/singleton-pattern.html
- WPF 中Canvas图形移动、缩放代码
从Flash转C#,很多内容一知半解,边摸索边前进,代码粗糙,权当留个脚印. 只是想得到一个基础的移动和缩放功能的界面,找了很久都是画线.画矩形等基础形状的代码,移动和缩放说的并不清晰,只能自己努力来 ...
- smarty 模板标签
smarty 模板标签 变量标签 数组变量标签 变量调节器 条件标签 循环标签 数组变量标签 模板加载标签 预定义变量标签 常量标签
- c#里面如何激活一个外部程序进程并显示在最前
using System.Diagnostics; using System.Runtime.InteropServices; [DllImport("user32.dll")] ...
- tomcat内存设置问题
一. tomcat内存设置问题 收藏 在使用Java程序从数据库中查询大量的数据或是应用服务器(如tomcat.jboss,weblogic)加载jar包时会出现java.lang.OutOfMemo ...
- [日常] Go语言圣经--复合数据类型,数组习题
go语言圣经-复合数据类型 1.以不同的方式组合基本类型可以构造出来的复合数据类型 2.四种类型——数组.slice.map和结构体 3.数组是由同构的元素组成——每个数组元素都是完全相同的类型——结 ...
- 机器人数目-2015决赛Java语言C组第一题
标题:机器人数目 少年宫新近邮购了小机器人配件,共有3类,其中,A类含有:8个轮子,1个传感器B类含有: 6个轮子,3个传感器C类含有:4个轮子,4个传感器 他们一共订购了100套机器人,收到了轮子6 ...