ISNULL
? ?使用指定的替換值替換 NULL。
語法
? ? ? :ISNULL ( check_expression , replacement_value )
參數
check_expression ?將被檢查是否為NULL的表達式。如果不為NULL,這直接返回 該值,也就是 check_expression 這個表達式。如果為空這個直接返回 replacement_value這個表達的內容。check_expression?可以是任何類型的。
replacement_value?在 check_expression為 NULL時將返回的表達式。replacement_value 必須與 check_expresssion 具有相同的類型。
返回類型
返回與 check_expression 相同的類型。
注釋
如果 check_expression 不為 NULL,那么返回該表達式的值;否則返回 replacement_value。
示例
1 示例數據
表tb_Student及其示例數據如下圖所示。
?2.查詢要求
? ?查詢出其中成績(score)小于等于60的學生信息保存至表變量@tempTable中,當學生成績為空時,成績記為0。
declare?@tempTable?table( ????stuname?nchar(10), ????stuage?int, ?????stuscore?float); insert?into?@tempTable select?name,age,ISNULL(score,0)?from?tb_Student where??ISNULL(score,0)<p><strong>3 執行結果</strong></p><p><img src="https://img.php.cn/upload/image/671/793/259/1592296307180157.png" title="1592296307180157.png" alt="76a0447ec8e6c00e3c6c263ebb29962.png"></p><p>推薦教程: 《<a href="https://www.php.cn/shujuku-tutorials.html" target="_blank">sql教程</a>》</p>
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END