Sql server SQL SERVER(2008)调试IF条件

Sql server SQL SERVER(2008)调试IF条件,sql-server,sql-server-2008,Sql Server,Sql Server 2008,如果sql Server中存在条件规则,是否有方法调试sql Server 最好是对sql 2008有一个答案,但如果只有在以后的版本中才有可能,那么请告诉我,因为我无法通过询问@Google找到这个答案 例如: DECLARE @note4 nvarchar(max) select @note4 = note4 from inserted DECLARE @profileid int select @profileid = profileid from ins

如果sql Server中存在条件规则,是否有方法调试sql Server

最好是对sql 2008有一个答案,但如果只有在以后的版本中才有可能,那么请告诉我,因为我无法通过询问@Google找到这个答案

例如:

    DECLARE @note4 nvarchar(max)
    select @note4 = note4 from inserted

    DECLARE @profileid int
    select @profileid = profileid from inserted


    IF (@note4 <> '' and @note4 is not null and @profileid in (123,1234))
    BEGIN
        --some code goes here
    END
DECLARE@note4 nvarchar(最大值)
从“插入”菜单中选择@note4=note4
声明@profileid int
从插入的文件中选择@profileid=profileid
如果(@note4''和@note4不为null,并且(1234)中的@profileid)
开始
--这里有一些代码
结束
那么,当我进行调试时,是否有办法查看返回这些条件的内容

@note4 <> ''
@note4 is not null
@profileid in (123,1234)
@note4''
@注4不为空
@中的profileid(1234)

它们是假的还是真的?

如果你真的想知道每一个都返回了什么,你可以在主菜单之前执行以下操作:

IF (@note4 <> '') 
BEGIN 
PRINT 'true @note4 <> '''''
END
IF (@note4 is not null) 
BEGIN 
PRINT 'true @note4 is not null'
END
IF (@profileid in (123,1234)) 
BEGIN 
PRINT 'true @profileid in (123,1234)'
END
IF(@note4'')
开始
打印“true@note4”
结束
如果(@note4不为空)
开始
打印“true@note4不为空”
结束
IF(@profileid in(1234))
开始
在(1234)中打印“true@profileid”
结束

您可以只选择条件?尝试添加到监视,只需条件
“IF(@note4''和@note4不为null且@profileid in(123))”无法计算
,如果我只选择了其中的一部分,则无法计算相同的结果
“@note4''”
我不确定您要到哪里去,但是取决于
——这里有一些代码
,您最好只使用基于连接的逻辑,而不是基于IF的逻辑(毕竟SQL是基于集合的逻辑构建的,所以最好使用它)。通过对测试数据运行查询,它将使测试变得更加容易。@AllanS.Hansen嗯,我更感兴趣的是能够看到哪些条件返回true,哪些条件返回false。(不仅在本例中,而且在一般情况下)因为我现在没有问题,但过一段时间后可能会有问题,所以我想确保我知道如何调试此代码。很抱歉,我不能更改代码。嗯,我想问一下调试的问题。当然,你们可以像这样添加行,但当我调试时,我想知道我是否可以看到,如果条件满足,会返回什么。在这个提供的代码中,您可以轻松地修改以查看,但如果代码长得多怎么办?我不想把所有的时间都用手加上,那太恶心了。