在不评估的过程中多次选择

时间:2016-11-15 06:26:45

标签: sql-server stored-procedures

我的程序如下

BEGIN
    DECLARE @CNT int =33, 
            @mlogin VARCHAR (1) = 'm',
            @concusers INT ='33' ;

    SELECT 
        @CNT = COUNT(*) 
    FROM 
        USRINF u, usrdpf usr   
    WHERE 
        u.userid = usr.userid 
        AND u.LOGOUT_TIME IS NULL 
        AND u.USERID = @USERID ;

    SELECT 
        @mlogin = mlogin, @concusers = concusers 
    FROM 
        usrdpf upf    
    WHERE  
        upf.USERID = @USERID ;

    PRINT @mlogin;-----m
    PRINT @concusers;-----33
    PRINT @CNT ; ----0

    IF (@mlogin = 'Y' AND @CNT < @concusers)

第二个select语句没有执行,执行后我可以看到@mlogin@concusers值作为我指定的默认值,分别是'm'和''33'而@cnt是为什么会这样?

0 个答案:

没有答案