[ACCEPTED]-How do I make this SQL statement return empty strings instead of NULLS?-null

Accepted answer
Score: 12

You can use the COALESCE function to avoid getting 4 nulls. Basically it returns the first non-null 3 value from the list.

SELECT COALESCE(dateField, '') FROM Some_Table

This is an ANSI standard, though 2 I have noticed that it isn't available in 1 Access SQL.

Score: 3

You can use CASE:

CASE WHEN MyField IS Null THEN ''
ELSE MyField
End As MyField

0

Score: 2
select max(isnull(modifydate, "default date") from scormtrackings where...

will work as long as there is at least one 3 row that satisfies the where clause, otherwise 2 you will still get NULL

select IsNull( max(modifydate), "default_date") from scormtrackings where ...

should work in all 1 cases

Score: 0
select max(isnull(Date,"default date")) .....

0

Score: 0

This works too... hate to admit how often 4 I use it!!

Declare @LastAccessed varchar(30)

Select 3 @LastAccessed = max(modifydate) from scormtrackings 2

Set @LastAccessed = isnull(@LastAccessed,'')

Select 1 @LastAccessed as LastAccessed

Score: 0

You can use NVL.

NVL(<possible null value>,<value to return when arg1 is null>)

0

More Related questions