ODBC query on MS SQL Server returning first 255 characters only in PHP PDO (FreeTDS)

后端 未结 4 2006
长发绾君心
长发绾君心 2020-12-19 09:33

I\'m currently trying to pull some data from a SQL Server database view that we have restricted access to from our Linux web server.

We don\'t need to edit the data

4条回答
  •  北海茫月
    2020-12-19 10:18

    According to the FreeTDS User Guide, the issue seems to be that FreeTDS can only handle varchar up to 255 characters when talking to SQL Server "due to limitations inherent in the protocol definition". Anything bigger than that needs to be data type text.

    You can resolve the issue either by modifying your schema accordingly, or converting the data type during your query, like this:

    SELECT CAST(mycol as TEXT) FROM mytable
    

提交回复
热议问题