简体   繁体   中英

SQL Server error - Operand type clash: ntext is incompatible with int - (I'm not even using "ntext")

One of the columns I'm operating on is:

Comments VARCHAR(8000)

So basically I'm trying to insert a large text of up to even 600 characters into this column Comments . When I run my script everything goes smoothly for first 10 rows then all of a sudden I get this error:

pypyodbc.DataError: ('22018', '[22018] [Microsoft][ODBC SQL Server Driver][SQL Server]Operand type clash: ntext is incompatible with int')

Then again if I rerun the query, everything will start going smoothly for next 10 rows and as you might have guessed by now I get the same error again.

What can I do to fix this?

Edit :

I have tried using VARCHAR(MAX) , NVARCHAR(MAX) , VARCHAR(800) , TEXT . I get the same error every time.

I wonder whether it is a problem with the data on row 10? To test this, try deleting the data on, say, row 5, and see whether the error starts on row 9.

I would recommend you using pmyssql instead of pypyodbc. Seems like it is a driver level issue and switching to pymssql might help. Please follow the ACOM doc and let me know if that helps. If you still run into the same issue let me know as I can further try to help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM