怎么检验一个字段里面有没有数据(sql server)

来源:百度知道 编辑:UC知道 时间:2024/05/13 07:59:58
我是想检验有没有重复的数据,不是要查询出不重复的数据

你是想用SQL语句操作吗?如果是的话可以这样写:举个例子检验某个特定列的city字段是否为空,
declare @return varchar(20)
set @return=(select city from authors where au_id='172-32-1176')
if @return is null
print '为空'
else
print '不为空'

select * from [表名] where 字段名 is null or 字段名 = ''
这是查出所有字段为空的数据

select * from [表名] where 字段名 is not null or 字段名 <> ''
这个是查出字段不为空的数据

在查询的时候直接加上distinct
如从table表里查询没有重复的姓名name,
select distinct name from table

if(dateReader[0] is DBNull)
{
//没有数据
}
else
{
//有
}

字段 is not null