rubysql-serverfreetdsvarcharmax

Ruby 2.0 on windows connecting to MS SQL varchar(max) truncating to 2048


background: i have written a few ruby transformation scripts they get data from MS SQL transform them and then store it back to the data base i am using tiny tds gem which works over freetds

--Problem: for columns in sql that are varchar max and have string length greater than 2048 when data is extracted using tiny tds these columns get truncated to 2048 length exactly.

Freetds protocol 7.2 does fix this issue but is not available on windows platform the code works perfectly on a mac. but due to integration with ETL tool i have to deploy it on a windows machine.

-- does any one have a solution for this.


Solution

  • I don't have any code doing this myself, but have you tried using the set textsize command. I think the default is 2048.

    From the MS article on Set TextSize

    The SQL Server Native Client ODBC driver and SQL Server 
    Native Client OLE DB Provider for SQL Server automatically 
    set TEXTSIZE to 2147483647 when connecting.
    

    But I think you may need to call this explicitly (using the same connection, prior to getting data).