我正在尝试执行此查询,但我不断收到错误消息
Msg 102, Level 15, State1
Incorrect syntax near ')'.
你能看看我的查询吗?我相信每个 SQL 关键字我都添加了适当的括号。
USE [db]
GO
SET NOCOUNT ON
DECLARE @AlertDateTime date
, @HostName varchar(50)
, @Program varchar(100)
, @Event varchar(100)
, @Entity varchar(50)
, @Class tinyint
, @Severity tinyint
, @AlertMessage varchar(1024)
, @SkipFlag char(1)
select cast(getdate() as date)
IF EXISTS
(SELECT * FROM SendAlertLog
WHERE EXISTS
(
SELECT SendAlertLog.Event
FROM SendAlertLog
GROUP BY SendAlertLog.Event
HAVING COUNT (1) >= 2
)
AND SendAlertLog.SkipFlag != 'Y'
AND AlertDateTime <= DATEADD (mi,-30,@AlertDateTime)
)
我不知道我包含或排除了什么错误。请帮忙