create table tb(id int , val text) insert into tb values(1 , null) insert into tb values(2 , 'aa') go--原数据 select * from tb /* id val ----------- --------- 1 NULL 2 aa(所影响的行数为 2 行) */--查val is null的数据 select * from tb where val is null /* id val ----------- ------------ 1 NULL(所影响的行数为 1 行)*/drop table tb
if object_id('tempdb..#')is not null drop table # go create table #(ID int identity,[Name] text) insert # select 'adad' insert # select null insert # select '' select * from # where [Name]is null select * from # where cast([Name] as varchar(8000))='' /*ID Name ----------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 NULL(影響 1 個資料列)ID Name ----------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 3 (影響 1 個資料列)*/
insert into tb values(1 , null)
insert into tb values(2 , 'aa')
go--原数据
select * from tb
/*
id val
----------- ---------
1 NULL
2 aa(所影响的行数为 2 行)
*/--查val is null的数据
select * from tb where val is null
/*
id val
----------- ------------
1 NULL(所影响的行数为 1 行)*/drop table tb
go
create table #(ID int identity,[Name] text)
insert # select 'adad'
insert # select null
insert # select ''
select * from # where [Name]is null
select * from # where cast([Name] as varchar(8000))=''
/*ID Name
----------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2 NULL(影響 1 個資料列)ID Name
----------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 (影響 1 個資料列)*/