我正在尝试测试变量是否为空,但我似乎有语法错误,我的代码是:
DECLARE @count1 INT
SET @count1 =
(SELECT HPlayedHome FROM League WHERE GameID =
(SELECT TOP 1 GameID From Goals WHERE Date <= '20130923' AND Home = 'Palermo'
AND (GameID >=2551 AND GameId <= 5100) ORDER BY Date Desc))
SELECT CASE @count1 IS NULL THEN 0 ELSE @count1 END
我希望查询返回 @count1 的值,但如果它为 NULL,则返回 0。SQL SERVER 2012 突出显示 IS 上的语法错误,“IS 附近的语法不正确”。