Python with MS SQL - truncated output

十年热恋 提交于 2019-12-01 19:49:26

Change the text size in global section of freetds.conf to the maximum (4294967295 bytes):

[global]
    tds version = 8.0
    text size = 4294967295

Also have to set TEXTSIZE in SQL to maximum (2147483647 bytes):

sql = """
    SET TEXTSIZE 2147483647;
    SELECT  Req.ID,
            ShReq.Summary AS [Short Name],
            ShReq.ALM_SharedText AS [Text],
            Req.ContainedBy,
            Req.DocumentID
    FROM    CurMKS..ALM_Requirement Req
            JOIN CurMKS..ALM_SharedRequirement ShReq ON Req.[References] = ShReq.ID
    WHERE DocumentID = 111111;
      """

If you are using the older version of pymssql (1.0.2), there are certain limitaions.

varchar and nvarchar data is limited to 255 characters, and longer strings are silently trimmed. This is known limitation of TDS protocol. A workaround is to CAST or CONVERT that row or expression to text data type, which is capable of returning 4000 characters.

source: http://pymssql.sourceforge.net/limitations.php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!