Skip to content
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

_tds.OperationalError: Received an invalid column length from the bcp client for colid... #66

Open
gizmo93 opened this issue Feb 19, 2020 · 3 comments

Comments

@gizmo93
Copy link

gizmo93 commented Feb 19, 2020

When trying to bulk insert a String into a VARCHAR(MAX), NVARCHAR(MAX) field, we get this error message.

CTDS version: 1.11.0
FreeTDS version: 1.00.80
Python 3.7
Windows 10 64 bit

Example:

CREATE TABLE dbo.Test
(
Id INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
FancyCol INT NOT NULL,
[Value] NVARCHAR(MAX)
)

CREATE TABLE dbo.Test2
(
Id INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
FancyCol INT NOT NULL,
[Value] NVARCHAR(4000)
)

Code to reproduce (sorry, really had problems to get the code properly formatted inside the Github Editor)
test.txt

@gizmo93 gizmo93 changed the title _tds.OperationalError: Received an invalid column length from the bcp client for colid 8. _tds.OperationalError: Received an invalid column length from the bcp client for colid... Feb 19, 2020
@joshuahlang
Copy link
Collaborator

If I'm understanding correctly, you're reporting the behavior documented here: https://zillow.github.io/ctds/bulk_insert.html#text-columns

As far as I know, this is a deficiency in FreeTDS' implementation of BUILK INSERT

@gizmo93
Copy link
Author

gizmo93 commented Feb 20, 2020

Hey, there are no problems with "normal" VARCHAR/NVARCHAR columns, they work as expected, if I wrap them in ctds.VarChar().
Problem seems to be only when trying to BULK INSERT into a VARCHAR/NVARCHAR (MAX) column.
Is there any solution / workaround for this?

@kafran
Copy link

kafran commented Apr 27, 2020

Avoid varchar/nvarchar (max). Use ntext instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants