sql中怎么判断一个常数是否为空?

来源:百度知道 编辑:UC知道 时间:2024/06/14 04:32:17
知道sql中怎么判断一个常数是否为空嘛?
if(@a == null)
{

}
这样好像错了

if @a is null then这样?
这样好像也有问题

if (@a is null)
begin

语句块

end
else
begin

语句块

end

如还有不清楚,请参考SQL帮助文档,关键字'if' 'is null',有相关示例

PL/SQL 中:

IF VAR IS NULL THEN
NULL;
END IF;

if @a is null
begin

end
if 后面没有then

if @a is null then
NULL
end

declare
@a varchar(20)
if @a is null
print'ok'
我这样写好用啊
你在试试