怎么判断select 出来的记录为空

[复制链接]
查看11 | 回复7 | 2008-5-6 14:02:45 | 显示全部楼层 |阅读模式
if exists(select * from table where isnull(列名,'')='')beginSqlendelsebeginSqlend原理就是这样,其它的可以根据你查的结果进行修改
回复

使用道具 举报

千问 | 2008-5-6 14:02:45 | 显示全部楼层
select 字段 into v_char from 表;if(v_char is null)执行(另一条select语句) else
回复

使用道具 举报

千问 | 2008-5-6 14:02:45 | 显示全部楼层
空值返回 NULL…… 或者看你的数据库手册看看空值返回什么……
回复

使用道具 举报

千问 | 2008-5-6 14:02:45 | 显示全部楼层
举个例哈declare @CardStatus tinyintselect @CardStatus = CardStatus from Cardswhere 条件IF (@CardStatus IS NULL) BEGIN...END ELSE BEGIN...END不是0 是空拉字段=""么就行了呀
回复

使用道具 举报

千问 | 2008-5-6 14:02:45 | 显示全部楼层
有点问题declare @count int select @count =count(*) from table where 条件if (@count>0)
begin
执行另一条语句 end else
begin
select col1,col2, from table where 条件 end
回复

使用道具 举报

千问 | 2008-5-6 14:02:45 | 显示全部楼层
(select * from table ) is null
回复

使用道具 举报

千问 | 2008-5-6 14:02:45 | 显示全部楼层
用游标啊!!!!!!!!不用游标就要用上面那几个哥们儿写的方法了。但有游标干吗不用
回复

使用道具 举报

千问 | 2008-5-6 14:02:45 | 显示全部楼层
使用count查询啊,判断结果是否为0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行