Page 1 of 1

Dealing with Null columns

Posted: Mon Dec 13, 2004 1:35 pm
by yaminids
Hello there,

I have the following columns in a table: 'Name', 'ssn, 'age'.
The values for these columns are:

SUN 6666 24
5555 26
Raj 7777 25
8888 23

The first column contains Null values. I am trying to separate this into two files based on the column 'Name'. I am using IsNull(Name) then 'file1' else 'file2' condition. This is working fine when the value in the 'Name' column is 'null'. But when there are some spaces in the 'Name' column instead of Null this condition is not working.

Can anyone explain to me what the problem is.

Thanx in advance.
-Yamini

Posted: Mon Dec 13, 2004 1:56 pm
by kcbland
NULL is not the same as spaces. ISNULL is used to detect for the null condition, but to check for spaces requires that you do a string comparison.

If you want to trim for spaces and then check for blank and also deal with the null condition, use the following statement:

Code: Select all

NOT(ISNULL(link.column)) OR LEN(TRIM(link.column)) > 0
Non-spaces or not null will evaluate to TRUE.

Posted: Mon Dec 13, 2004 2:06 pm
by ketfos
Hi,

Can you paste your code with the sample input you are using?

It appears you doing correct.

Ketfos