[freetds] empty strings select as null bug

Jeffrey Shaw shawjef3 at gmail.com
Wed Jun 10 10:27:13 EDT 2015


When I reported this dblib bug to this list before I got it backwards. I
said NULL strings were being selected as empty strings, but it's the other
way around.

When I use TDS Version >= 7.0, empty strings are selected as NULL.

When I use TDS Version = 4.2, empty strings are empty.

I have a table in SQL Server 2008 R2 that is (int, varchar(max)). I insert
one row with an empty string. Selecting it from management studio gives
this:

select id, case when string is null then 1 else 0 end AS [is null] from
dbo.strings

id    is null
1    0

I can use PostgreSQL's tds_fdw to use dblib to select from SQL Server. The
query is

select id, string is null from distribution.dbo_strings;

TDS Version = 4.2
id | ?column?
----+----------
  1 | f

TDS Version = 7.0
 id | ?column?
----+----------
  1 | t


More information about the FreeTDS mailing list