Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.
If an application opens a connection (successfully) to SQL Server, and leaves it open in anticipation of sending a (or possible 'another') query, and in the meantime, SQL kills that connection for some reason (eg, service restarts, or a kill command is sent), then when the connection (which thinks it's open) tries to send a command, you'll get this error.
So catch the error in your application, and reconnect. Then try the command again.
I mostly see this error if for some reason the network connectivity was lost, even for a few seconds. That could be someone disconnecting a cable, an unstable wifi connection, a bad network switch, computer that goes to sleep (it's on by default on Win7 and up), Windows update updating a network driver, etc.
I ran across the same error a while back and meant to post my answer, but I couldn't log in and simply forgot. I happened upon this question again and will give my answer as best as I can remember as it's quite obscure and I could find no mention of it anywhere else.
This error is returned from MS-SQL databases when passing some form of invalid date to an SP from .NET (and potentially other sources). IIRC, I was passing in a .NET MinDate (ie. default value). Basically, just check your date parameters and make sure they are sensible!
I got this error due to SQL Server not liking one of my commented out lines of SQL.
My advice is to start with the simplest code to validate that it is not a connection issue and then work up from there.
The commented out line was --EXEC master..xp_cmdshell 'bcp ... for which the remote computer did not have permission to run.
There is an almost identical line later on in the code that was accepted, so I think this is some vague security patch error.
You would think a commented out line would have no affect on connectivity issues, but here we are.