2

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.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
90abyss
  • 7,037
  • 19
  • 63
  • 94
  • It looks like you are using the `{SQL Server}` ODBC driver which is very old and pre-dates Azure. Perhaps try using the `{SQL Server Native Client 11.0}` driver and see if that helps. – Gord Thompson Oct 20 '15 at 23:43
  • Tried that - still getting same error :( – 90abyss Oct 21 '15 at 00:11
  • I have the same problem: it seems that pypyodbc(pyodbc has same prob) converts your variable into something bogus.. The problem is some incompatibility between SQL-Server ODBCs Typeinfo and pyodbc.. sometimes I am wondering: SQL-DBs are more than 40 years old.. somebody should fix this stuff :( – Peter Parker Mar 20 '16 at 23:22

2 Answers2

1

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.

NeilM
  • 31
  • 3
  • I tried doing that - but to no avail. I am only able to insert 8 to 10 rows in one go and then the above error pops up. When I rerun the query again it works for a different set of 8 to 10 rows and then again stops.The script works perfectly but only for a limited time - so the script is 100% correct bcoz the data is stored in the db properly. – 90abyss Oct 21 '15 at 02:50
0

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.

Pang
  • 9,564
  • 146
  • 81
  • 122
meet-bhagdev
  • 2,608
  • 18
  • 22