从SQL Server中选择Null值 [英] Select Null values from SQL server
本文介绍了从SQL Server中选择Null值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从SQL数据库中选择空值?
这是我的代码:
SQcon.Open();
SQcmd = new SqlCommand( SELECT COUNT (*)作为'count'来自dbo.INVENTORY WHERE INV_NO =,SQcon);
然而它给我的语法不正确。
我需要获得带有空值的INV_NO。
解决方案
你必须使用关键字IS,因为null无法与使用= < br $>
SELECT COUNT(*) as ' count' FROM dbo.INVENTORY WHERE INV_NO IS NULL 跨度> 的
how do I select null values from my SQL database?
here is my code:
SQcon.Open();
SQcmd = new SqlCommand("SELECT COUNT(*) as 'count' FROM dbo.INVENTORY WHERE INV_NO =", SQcon);
however its giving me an incorrect syntax.
I need to get INV_NO with null values.
解决方案
You have to use the keyword IS since null cannot be compared to using =
SELECT COUNT(*) as 'count' FROM dbo.INVENTORY WHERE INV_NO IS NULL
这篇关于从SQL Server中选择Null值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文