Monday, February 27, 2012

Handling null in a result

-
--if the following is null, then do not print
substring (m.gldebitacct, 1, 6)+ '.' + w.wo2 + '.' + w.wolo5 + '.' + substring (m.gldebitacct, 8, 7) + '.' +
w.wonum as PROJ,
-

How do I ignore the row that contains a null and move on to the next record?

hanks,

daveYou can use IS NULL in the predicate to compare a column to NULL. And there is an ISNULL() expression that you can use to return something else than NULL, for example in a select clause... Best regards Michael <kscdavefl@.discussions..microsoft.com> wrote in message news:2ce801e7-3912-4038-b5c4-5c3adb726674@.discussions.microsoft.com...---if the following is null, then do not printsubstring (m.gldebitacct, 1, 6)+ '.' + w.wo2 + '.' + w.wolo5 + '.' + substring (m.gldebitacct, 8, 7) + '.' +w.wonum as PROJ,-How do I ignore the row that contains a null and move on to the next record?hanks,dave|||AND this to the WHERE clause:

... AND substring (m.gldebitacct, 1, 6)+ '.' + w.wo2 + '.' + w.wolo5 + '.' + substring (m.gldebitacct, 8, 7) + '.' +
w.wonum IS NOT NULL

I'd also remove the SUBSTRING function.

alternatively you could do this:

... AND (m.gldebitacct IS NOT NULL AND w.wo2 IS NOT NULL AND w.wolo5 IS NOT NULL AND m.gldebitacct IS NOT NULL)

Any member of your concatenated string that has a NULL value will cause the entire concatenated string to be NULL.

No comments:

Post a Comment