Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
查找日志(a)';如果SQL server 2008 R2上的a为空,则为s值类型。_Sql_Sql Server_Sql Server 2008_Exception_Windows 7 - Fatal编程技术网

查找日志(a)';如果SQL server 2008 R2上的a为空,则为s值类型。

查找日志(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) 谢谢空

我需要在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)


谢谢

空值不是零。传递给任何标量函数的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
来证明它。