sql
server
中使用
is
null
或
not
来处理列的空值.
语法为:
列名
(字段为空返回true
,不为空返回
false)
(字段为空返回false,不为空返回
true)
例:
select
case
when
a
then
else
end
from
aaa
语法大意:如果a列
为空显示1,不为空显示0
在sql中
空值有NULL 和''的形式
当是NULL的时候用 IS NULL判断
当是''的时候用 =''判断
比如
select * from table where enddate IS NULL;
select * from table where str='';
create trigger DataProarea on testtable
for insert as
if exists(select * from inserted where TestFileds is null)
BEGIN
PRINT 'TestFileds是空值!'
ROLLBACK TRANSACTION
END
ELSE if not exists(select * from inserted join peopletable on inserted.TestFileds=peopletable.Peoplefileds)
begin
PRINT 'TestFileds的值在peopletable表的Peoplefileds中不存在!'
GO
where a is null
不是用等号,是用关键字"is"
不为空就是 is not null
①.、创建测试表,
select t.*, rowid from test_null t where value is null;
以上就是土嘎嘎小编为大家整理的sqlserver判空相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!