[freetds] Re: Inserting empty strings into MS SQL Server

Charles Bearden Charles.F.Bearden at uth.tmc.edu
Tue Aug 10 12:19:10 EDT 2004


> On Mon, 9 Aug 2004 James K. Lowden wrote:
>
> > Respectfully submitted, I think using zero-length strings to
> > circumvent non-null column policy isn't the best practice.
> > You're really saying there's no data for that column (in this
> > row), so NULL accurately reflects reality.  Zero-length strings
> > are very mysterious in ad-hoc queries, because it's hard to see
> > nothing.  And some versions of TDS can't distinguish between NULL
> > and a zero-length string, meaning that some clients will see a
> > NULL arriving from a (as declared) non-null column.  So, fwiw,
> > I think you're better off making your column nullable.  And you
> > get to avoid the bug in the bargain.  :-)

Thanks for your response.

I'm not sure what to think.  I had been pretty well persuaded that NULLs

and the three-value logic they entail were a bad thing, and frankly that

was after I had come to see them as a big annoyance since they don't
work 
with parameter placeholders in WHERE clauses.

Both you and Joe Geiser refer to problems the use of empty strings
instead 
of NULLs causes.  It may be my lack of experience in RDBMs, but it's not
yet 
clear to me exactly what the nature of those problems is.  In fact,
others 
have told me the same thing about NULLs, namely that they break
relational 
models and will reach back and bite you at unexpected times.  I do know
that 
I find NULLs inconvenient because I can't test for them with the same 
operators as I use to test for non-NULL values.  Are there some good,
simple  
examples of the problems caused by the use of empty strings instead of 
NULLs?

> >           And some versions of TDS can't distinguish between NULL
> > and a zero-length string, meaning that some clients will see a
> > NULL arriving from a (as declared) non-null column.  

This is a bug, right? :-)  Or at least a flawed implementation?

Thanks,
Chuck




More information about the FreeTDS mailing list