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
WHERE c.name = a.name
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.