Select from following answers:- 10
- 1900-01-01 00:00:00.000
- 1900-01-11 00:00:00.000
- Error
- All Above
Coalesce evaluates the arguments in order and returns the current value of the first expression that initially does not evaluate to NULL.
Here first not-null expression is 10. But why it returned 1900-01-11 00:00:00.000 ?
Reason:
COALESCE follows the CASE expression rules and returns the data type of value with the HIGHEST PRECEDENCE.
Here DATETIME has highest precedence than int... So it adds 10 days to default date 1900-01-01 00:00:00.000 . In that way it returns 1900-01-11 00:00:00.000
Show Correct Answer
Asked In: Many Interviews |
Alert Moderator