jfreeman2010
asked on
t-sql coalesce problem with space in column value
t-sql coalesce problem with space in column value
I have a SQL select statement using coalesce as following
SELECT COALESCE (A.FIRST_NAME, B.FIRST_NAME) AS FIRST_NAME,
COALESCE (A.LAST_NAME, B.LAST_NAME) AS LAST_NAME
FROM TEST_A A
INNER JOIN TEST_B B
ON A.ID = B.ID
It works as long as the A table column if is null, it shows the b table data.
My problem is table A has value of '' (space, not null value).
What can I do to fix this?
I have a SQL select statement using coalesce as following
SELECT COALESCE (A.FIRST_NAME, B.FIRST_NAME) AS FIRST_NAME,
COALESCE (A.LAST_NAME, B.LAST_NAME) AS LAST_NAME
FROM TEST_A A
INNER JOIN TEST_B B
ON A.ID = B.ID
It works as long as the A table column if is null, it shows the b table data.
My problem is table A has value of '' (space, not null value).
What can I do to fix this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks!!!
ASKER
What I am looking is if A.last_name is null or space or '', return value from b.last_name.
thanks,