查找日志(a)';如果SQL server 2008 R2上的a为空,则为s值类型。
我需要在SQL server 2008 R2上找到该日志(null)的值类型查找日志(a)';如果SQL server 2008 R2上的a为空,则为s值类型。,sql,sql-server,sql-server-2008,exception,windows-7,Sql,Sql Server,Sql Server 2008,Exception,Windows 7,我需要在SQL server 2008 R2上找到该日志(null)的值类型 DECLARE @factor1 float set @factor1 = log(null) if @factor1 is null print '@factor1 is '+ cast(@factor1 as varchar(100)) if isnumeric(@factor1) = 1 print '@factor1 is num' 为什么日志没有引发异常(null) 谢谢空
DECLARE @factor1 float
set @factor1 = log(null)
if @factor1 is null
print '@factor1 is '+ cast(@factor1 as varchar(100))
if isnumeric(@factor1) = 1
print '@factor1 is num'
为什么日志没有引发异常(null)
谢谢空值不是零。传递给任何标量函数的NULL将返回NULL。(异常:当然,UDF代码可以检测null并故意抛出异常。) 从概念上讲,NULL表示“我不知道!”。“我不知道”的对数是我不知道的。我不知道它是否存在 如果要在源值为NULL时出错,请尝试:
LOG(COALESCE(NULL,0))
假设您想要一条空值的消息,您应该处理@factor1的空值 不能将字符串与NULL串联,它将生成NULL
DECLARE @factor1 float
set @factor1 = log(null)
if @factor1 is null
print '@factor1 is '+ isnull(cast(@factor1 as varchar(100)),'null')
if isnumeric(@factor1) = 1
print '@factor1 is num'
返回:
@因子1为空
对null的任何操作通常都是null,但您可以执行
DECLARE@factor1 float;设置@factor1=log(空);选择@factor1
来证明它。