Our Brands

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

Welcome to the Schneider Electric Website

Welcome to our website.
		
How can we help you today?
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 batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown

Product Line
Power Monitoring Expert 7
Power Monitoring Expert PMEv8.x

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 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 '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.

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 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.

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

Schneider Electric Egypt and North East Africa

Users group

Discuss this topic with experts

Visit our community and get advice from experts and peers on this topic and more

Need help?

  • Start here!

    Find answers now. Search for a solution on your own, or connect with one of our experts.

  • Contact Support

    Reach out to our customer care team to receive more information, technical support, assistance with complaints and more.

  • Where to buy?

    Easily find the nearest Schneider Electric distributor in your location.

  • Search FAQs

    Search topic-related frequently asked questions to find answers you need.

  • Contact Sales

    Start your sales inquiry online and an expert will connect with you.

I'd like to receive news and commercial info from Schneider Electric and its affiliates via electronic communication means such as email, and I agree to the collection of information on the opening and clicks on these emails (using invisible pixels in the images), to measure performance of our communications and improve them. For more details, please read our Privacy Policy.

  • Products Documentation
  • Software Downloads
  • Product Selector
  • Product Substitution and Replacement
  • Help and Contact Center
  • Find our Offices
  • Get a Quote
  • Where to buy
  • Careers
  • Company Profile
  • Report a misconduct
  • Accessibility
  • Newsroom
  • Investors
  • EcoStruxure
  • Job Search
  • Blog
  • Privacy Policy
  • Cookie Notice
  • Terms of use
  • Change your cookie settings