I am importing States into a table and need to change all NULL fields before I perform a lookup. I'm using a derived column to replace the state value. I'd like to find all States that are blank and set it to "--".
Ironically, this works:
State != "" ? State : "--"
but
State == "" ? State : "--"
Does not work
Can someone tell me why?
Just a guess: the State column really has NULL values (vs. empty strings), which never compare equal to anything. But to explain why the first approach works, there must be some kind of implicit conversion going on.
I think the right way to express what you mean is:
isnull(State) ? "--" : State
|||Or State is a " " (space), not "". Check for both-
ISNULL(State) ? "-" : TRIM(State) == "" ? "-" : State
|||Thanks, the state was not really null, but empty string
No comments:
Post a Comment