日期:2014-05-17  浏览次数:20409 次

sql中Isnull不起作用


select Isnull(CertificateNo,'G检D类140130001')
from T_WeiTuoBook 
where AreaId='3' and SubDepart='3' and DeviceType='D' and Isnumeric(Right(CertificateNo,7))=1
and substring(CertificateNo, 5,2) = right(year(getdate()),2)

当CertificateNo没有最大值时,我想把‘G检D类140130001’作为默认值。但是结果如图,什么也没有,请问是怎么回事?
------解决方案--------------------
select Isnull((select CertificateNo from T_WeiTuoBook where AreaId='3' and SubDepart='3' and DeviceType='D' and Isnumeric(Right(CertificateNo,7))=1
and substring(CertificateNo, 5,2) = right(year(getdate()),2)),'G检D类140130001')