gpt4 book ai didi

sql-server - SQL Server : How to check if the value of returned field is not null

转载 作者:行者123 更新时间:2023-12-02 17:26:07 26 4
gpt4 key购买 nike

我的SQL语句如下:

SELECT  ReturnDate
FROM <joins>
WHERE <conditions>

如何检查 ReturnDate 是否不为空?

最佳答案

您可以将 CASEIS NULL 一起使用(或IS NOT NULL):

SELECT CASE 
WHEN ReturnDate IS NULL THEN 'It is null'
ELSE 'It is not null'
END AS IsItNull
FROM dbo.tablename ....

如果您需要过滤 NULL/NOT NULL 值,您还可以使用 IS NOT NULL:

WHERE ReturnDate IS NOT NULL  ...

关于sql-server - SQL Server : How to check if the value of returned field is not null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18487257/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com