|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, October 12, 2010 4:24 AM
Points: 41,
Visits: 102
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 11:21 AM
Points: 2,163,
Visits: 2,148
|
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Yesterday @ 7:11 AM
Points: 877,
Visits: 1,159
|
|
Good one point question. Thanks
Thanks
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Yesterday @ 7:11 AM
Points: 877,
Visits: 1,159
|
|
As per the BOL: If all arguments are NULL, COALESCE returns NULL with Note: At least one of the null values must be a typed NULL.
Then why "SELECT COALESCE(NULL,NULL) AS [COALESCE]" is failed?
Thanks
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 5:40 AM
Points: 2,640,
Visits: 4,555
|
|
Because in this case ALL the arguments are "untyped" nulls.
so declare @a int select coalesce(@a,null)
will retunr NULL (and not an error).
Mike
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Monday, September 17, 2012 7:30 AM
Points: 1,038,
Visits: 679
|
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 1:05 AM
Points: 753,
Visits: 713
|
|
An interesting question, but am I missing something here? When would you use coalesce entirely with untyped values?
If I were using coalesce it would be to test column values or variables/parameters and in both these cases typing is specified. Can anyone think of a situation where you would be sending only untyped values?
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 3:58 AM
Points: 3,191,
Visits: 4,149
|
|
I found it interesting that the expression "ISNULL(NULL, NULL)" is of type INT.
SELECT ISNULL(NULL, NULL) AS A INTO QOTD_TABLE;
EXEC sp_help 'QOTD_TABLE';
-- Column_name Type -- ------------- ------ -- A int Is there any reasonable explanation on this behavior?
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 6:28 AM
Points: 1,258,
Visits: 4,259
|
|
| Interesting point there, vk-kirov. I guess that means that the default type for NULL is int--but in that case, there's not really any such thing as an "untyped NULL" and the COALESCE thing becomes a bit strange!
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: Today @ 6:39 AM
Points: 9,376,
Visits: 6,472
|
|
|
|
|