MS SQL 服务器,OutOfMemeryExceptions

MS SQL Server, OutOfMemeryExceptions

我正在为客户开发 Excel 报告工具。该工具正在广泛的数据库中使用。基本上它从特定的 table 中获取数据,并在 Excel 中为客户编写报告。到目前为止它一直在工作,但是在测试时我 运行 变成了 table,它超出了为检索数据分配的内存。

有什么办法可以解决这个问题吗?

不允许我在 SQL 服务器上更改分配的内存。

如有必要,我会提供任何代码,但我认为这不会给我的问题增加任何内容。

在使用 SSMS (SQL Server Management Studio) 将非常大的数据集返回到网格之前,我已经 运行 了解了这一点。如果它是 运行 在某些其他进程中,则不会发生错误,例如在从 SQL 代理作业启动的存储过程中。因此,您可能只是由于您的测试方法而引入了此错误。

SSMS 的内存限制为 2 GB,因为它是 32 位进程。可能是因为它基于 Visual Studio。

两个备选方案:将结果更改为使用较少内存的文本 (Ctrl+T),或将结果更改为保存到文件 (Ctrl+Shift+F) 使用驱动器存储而不是加载所有结果到记忆中。

注意:这些设置也位于执行计划选项旁边的工具栏中。

有一篇关于它的 Microsoft 知识库文章。 (https://support.microsoft.com/en-us/kb/2874903)

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.