Isn't it the case that an empty string is different from a null string?

  • At work I am working with one of our contractors. She was trying to add a new record to the one of our tables. However, it failed to enter the record, through an error that said, "Validation failed for one or more entities". When we investigated it more, we determined that the problem was she was trying to assign an empty string to a column named Item_Name, which is defined as a VARCHAR(120) field that is not nullable. Normally, that works, because an empty string is not a null. So, we then tried putting in a single blank character (' '), but that failed as well. We had to use something like “ABC” or anything that wasn’t both empty of blank characters.

    This doesn't make sense to me. I've inserted records into a VARCHAR column before that is defined as not being nullable, when the value being inserted was empty. Why weren't we able to do this? Is there some configuration that might be applied, either at the database or server level, which treats empty strings as nulls? Even if that were allowed, why would a space be treated like a null?

    Kindest Regards, Rod Connect with me on LinkedIn.

  • Oracle dbms treats an empty string as NULL.  Don't ask me why, it's totally bogus to me, but it does.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Really? Interesting. And it really bugs me because I know I've done this many times before.

    Kindest Regards, Rod Connect with me on LinkedIn.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply