New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bulk load error: While reading current row from host, a premature end-of-message was encountered. #212
Comments
I solved #197 by comparing how the bcp utility encodes If you look around the TDS spec, there are lots of one-off notes which say how image, text, and ntext act different or cause different tokens to be included in headers. It doesn't surprise me at all that there are edge cases Tedious doesn't handle. Hopefully you're already aware that the image type has been deprecated for over six years, and is likely going to be removed from SQL Server in the near future (you should be using varbinary instead). Quite honestly, everyone here works on this library in our free time, and tracking down a problem in a deprecated type doesn't seem like a very rewarding use of my limited free time. Maybe @patriksimek would be interested. If there's a problem with a non-deprecated type (like what happened with |
Hmm. I was not aware the Image type had been deprecated, but I am not surprised. My group just inherited a 3rd party DB from elsewhere on campus which uses it. Anyway, since I am bulk loading into a temporary table, then doing a join/update from there, I think I can get away with a VarBinary in the temporary table followed by a conversion as a work-around. Thanks for all your hard work on this project! |
Okay great. If you have problems with varbinary, then definitely post that and we'll look into it. |
I don't think it's worth digging into it. I was able to reproduce the issue but have no idea why this is happening. There is a note in docs:
Image is LONGLEN_TYPE as well, so this sounds to me like there is no support for IMAGE in bulk insert. What is more stranger is another note in the docs:
So, is XMLTYPE valid in bulk insert or not? It's not clear to me... |
Just another example of how terrible the TDS docs are. My first thought was to check the same things you did and see if there was a note saying whether image is a valid bulk insert type or not, and whether it should be encoded differently than usual, but I came away without a conclusion. I agree it's not worth digging into. |
I got a couple of this error before. It happens also when you don't have any row inserted in the loop. A typical case is that you have columns added, and then you take some array from other places, and iterate that array to insert row. Sometimes, when the array is empty, no row is inserted, and I'll get this error. So, better to check if the array is empty before execute the bulkload. |
While doing what should be a simple bulk load of some 32kb images (only one such image during testing), I get the following error message:
Here's my code:
Am I missing something? I feel like this may be related to #197.
The text was updated successfully, but these errors were encountered: