I have a datetime2 column called DocDate that I am trying to evaluate an ISNULL check against to return a blank '' value for instead of NULL.
A snippet of the statement:
SELECT TOP 100
DocumentId
,DocDate
,ISNULL(DocDate,'') AS 'DocDateEmpty'
FROM
DocDetails
WHERE
DocDate IS NULL
This returns: 1900-01-01 00:00:00.0000000
My WHERE clause clearly brings back only the rows that are explicitly NULL, so it is not an issue of DocDate being an empty string and evaluating to 0.
How can DocDate IS NULL evaluate correctly but ISNULL fails?
Per MSDN, ISNULL should evaluate the literal NULL value correctly and return an empty value.
Returns the same type as check_expression. If a literal NULL is provided as check_expression, returns the datatype of the replacement_value. If a literal NULL is provided as check_expression and no replacement_value is provided, returns an int.
