Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server Query Strange Output

I have the following SQL Server query:

SELECT ISNULL(MIN(P), 999) AS FLD
FROM (SELECT '0' AS P) AS T
WHERE (1 > 4)

How come the output of this query is '*' ?

Please explain

Thanks

like image 539
Sameh Avatar asked Dec 21 '22 07:12

Sameh


1 Answers

ISNULL uses the datatype of the first argument.

This is varchar(1) as that is the datatype of the literal '0'

999 would be truncated so SQL Server shows '*'

like image 179
Martin Smith Avatar answered Dec 22 '22 20:12

Martin Smith