An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown."
Asked Answered
T

7

12

I have one table(Sql server 2014) with 60 million data. while fetching the data i am getting

"An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown."

Can any one please help here?

Trillion answered 25/10, 2017 at 11:56 Comment(9)
Can you show us the code that throws this error ?Depredate
select * from tablenameTrillion
You never, ever want to do SELECT * FROM tablename .. do you have a WHERE clause on that? You are essentially pulling down the entire table.Bookbinder
Try searching for this ssms out of memory exceptionsGarish
yes i am using where clause but i have to fetch number of count of ID column.Trillion
You should show your queryOlla
Are you planning to fetch 60 million rows to the screen and then scroll to the end?Ostosis
This happens to me (even with small queries) since I often leave Management Studio open for days. I solve it by reopening the program or switching to "Results to text" (instead of grid)Prader
@MukundM select count(Id) FROM tablenameManducate
R
23

Close and re-open SQL Management Studio and see if that takes care of it. Mine does this from time to time even on small queries if I leave it open for too long or have too many query windows open.

Raynor answered 25/10, 2017 at 14:40 Comment(2)
I had 12 query windows opened remotely, I RDP the server directly and it worked for me. re-opening SSMS was the solution.Cavy
I had a similar issue instead of using select * from the table. Selecting some columns helped to resolve the issue.Outsail
E
2

Solution 1 : Close and re-opening SQL Server Management Studio and try querying.

Solution 2:

enter image description here

Eglantine answered 23/6, 2020 at 8:26 Comment(0)
B
1

Looks like SQL Management Studio memory leaking for long running sessions. Restart of it helps to solve this issue

Behling answered 17/5, 2019 at 13:13 Comment(0)
I
1

If you have opened so many new query editors in the SSMS, that can also cause this error. Try closing unnecessary tabs in SSMS.

Imaginative answered 20/11, 2019 at 21:10 Comment(0)
T
0

This exception is caused by SSMS process which is occupied by long running queries.Don't worry about it , you can try next time and run your query on next tab.

Thumbscrew answered 10/11, 2019 at 6:17 Comment(0)
B
0

In my case I was having problems even with tables with 8 rows. This worked for me:

  • Deleting Temp file present on %temp% location. If the problem still happens restart SSMS.

This happened due to unused temp files.

Blah answered 30/11, 2020 at 10:29 Comment(0)
M
0

After I deleted the temp file then it worked. Delete the file permanently Ctrl + Shift + Delete

Macaronic answered 25/4 at 7:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.