I have a Python program that connects to an MSSQL database using an ODBC connection. The Python library I'm using is pypyodbc.
Here is my setup:
- Windows 8.1 x64
- SQL Server 2014 x64
- Python 2.7.9150
- PyPyODBC 1.3.3
- ODBC Driver: SQL Server Native Client 11.0
The problem I'm having is that when I query a table with a varchar(max) column, the content is being truncated.
I'm new to pypyodbc and I've been searching around like crazy and can't find anything on how to prevent this from happening in pypyodbc or even pyodbc. At least not with the search terms I've been using and I don't know what other phrases to try.
I even tried adding SET TEXTSIZE 2147483647;
to my SQL query, but the data is still being truncated.
How do I prevent this from happening? Or can you point me in the right direction, please?
UPDATE:
So, I tried performing a cast in my SQL query. When I do CAST(my_column as VARCHAR(MAX))
it truncates at the same position. However, if I do CAST(my_column as VARCHAR(8000))
it gives me a larger set of the text, but it's still truncating some of the contents. If I try to do anything larger than 8000
I get an error saying that 8000
is the largest I can use. Anyone know what might be going on here? It seem strange that using MAX
won't work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…