ISNULL、COALESCE


◎ ISNULL

SELECT ISNULL(NULL,'1') AS 'Column_1'
SELECT ISNULL('0','1') AS 'Column_1'

◎ COALESCE

SELECT COALESCE(NULL,'1') AS 'Column_1'
SELECT COALESCE('0','1') AS 'Column_1'

某種程度上來說,ISNULL() 類似於 COALESCE(),但COALESCE()不同於ISNULL()的地方是,COALESCE()可以多載,且從第一個參數開始依序判斷,直到不是NULL的參數把它抓(印)出來

SELECT COALESCE(NULL, NULL, '2') AS 'Column_1'
SELECT COALESCE('0', NULL, '2') AS 'Column_1'

results matching ""

    No results matching ""