有人能告诉我这个SQL代码中的错误吗?

时间:2014-03-08 09:28:38

标签: sql-server tsql

Declare @Random int = 1, @Bool bit = 0;

WHILE (@Bool = 0)
    BEGIN
        SET @Random = ROUND(RAND()*(SELECT MAX(CharID) FROM SRO_VT_SHARD_INIT.dbo._Char where LastLogout < DATEADD(DAY, -3, CURRENT_TIMESTAMP),0)
        IF exists (SELECT CharID FROM SRO_VT_SHARD_INIT.dbo._Char WHERE CharID = @Random)
            BEGIN
                SET @Bool = 1 /*true*/
            END
    END
print @Random

它在CURRENT_TIMESTAMP之后给出错误,表示逗号附近有语法错误。如果我删除了0,那么ROUND函数没有足够的参数。有人?

1 个答案:

答案 0 :(得分:2)

更改

CURRENT_TIMESTAMP),0)

CURRENT_TIMESTAMP)),0)