Error occurred while executing batch. - by ScorpionJL

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 780790 Comments
Status Closed Workarounds
Type Bug Repros 2
Opened 3/6/2013 8:46:20 AM
Access Restriction Public


When running multiple select statements using a subquery with the MAX aggregate in the same session/connection I get the following errors intermittently:
An error occurred while executing batch. Error message is: Invalid array size.
An error occurred while executing batch. Error message is: Internal connection fatal error.
An error occurred while executing batch. Error message is: Non-negative number required. Parameter name: count
An error occurred while executing batch. Error message is: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

These errors occur applications written in C# (VS2010) code using the SqlDataReader referencing .NET 4.0 and accessing a SQL 2008 server.
They also occur using SSMS 2012(with and without SP1) and SSMS 2008 R2 when accessing an SQL 2008 or SQL 2012 server.

The error occurs on multiple machines.  The machines are running Windows 7 64-bit.  The error does not occur the on the first query.  It will often occur on the second or third query run in the same session.  The queries do not have to be in the same batch.

Example query that I can use to duplicate the error.  Yes it is a contrived example but the errors does occur on other queries, without the cross join and where the subquery references a different table.  Remember, the query has to be run multiple times for the error to appear.
SELECT TOP(300000) a.*
FROM sys.all_objects a
CROSS JOIN sys.all_objects b
WHERE a.object_id = 
( SELECT MAX(c.object_id)
  FROM sys.all_objects c

The error only seems to occur when connected directly to the same network as the server.  If I connect to my VPN and run the same query the error does not occur.  If I use a machine running Windows XP 32-bit the error does not occur.  The error does not occur when run directly on the server.

This sounds very similar to another error that was reported in 2008 but referred to SQL Server 2008 SSMS against an SQL Server 2005 databases.

The issue currently affects multiple existing applications that were previously running fine on other machines.
Sign in to post a comment.
Posted by Mini_Ed on 4/17/2013 at 3:28 AM
Just to add - I'm seeing the same thing when running from a 64 bit 2008 R2 server running 32 bit SSMS, sql server version 10.0.5768. I don't see the issue when running from a 32 bit xp machine. Furthermore, on the 64 bit server, Activity Monitor randomly fails to start correctly, with the following error :

The Activity Monitor is unable to execute queries against server [servername].
Activity Monitor for this instance will be placed into a paused state.
Use the context menu in the overview pane to resume the Activity Monitor.


Unable to find SQL Server process ID 5616 on server [servername] (Microsoft.SqlServer.Management.ResourceMonitoring)

Program Location:

at Microsoft.SqlServer.Management.ResourceMonitoring.SqlPerfmonProcessReader.GetSqlProcessCpuUtilization()
at Microsoft.SqlServer.Management.ResourceMonitoring.BackgroundSqlCpuTask.Execute()
at Microsoft.SqlServer.Management.ResourceMonitoring.BackgroundWorkRequest.Execute()
at Microsoft.SqlServer.Management.ResourceMonitoring.BackgroundWorkRequestQueue.BackgroundWorker_DoWork(Object sender, DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

Activity monitor from the 32 bit client is fine

Posted by Mini_Ed on 4/17/2013 at 3:10 AM
I'm getting similar behaviour when running a complex query from ssms, various errors or no error at all & the query completes, no consistency to the response.