August 7, 2015 at 12:50 am
Hi all - why does this query return;
12345
1234567890
SELECT ISNULL ( CONVERT(varchar(5), NULL), CONVERT(varchar(10), '1234567890') )
, COALESCE( CONVERT(varchar(5), NULL), CONVERT(varchar(10), '1234567890') )
Thanks!
--------------------------------------------
Laughing in the face of contention...
August 7, 2015 at 1:50 am
arrjay (8/7/2015)
Hi all - why does this query return;12345
1234567890
SELECT ISNULL ( CONVERT(varchar(5), NULL), CONVERT(varchar(10), '1234567890') )
, COALESCE( CONVERT(varchar(5), NULL), CONVERT(varchar(10), '1234567890') )
Thanks!
https://msdn.microsoft.com/en-us/library/ms190349.aspx
Data type determination of the resulting expression is different. ISNULL uses the data type of the first parameter, COALESCE follows the CASE expression rules and returns the data type of value with the highest precedence.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply