开发者

Inserting or Updating a table with 2 sub queries in SQL Server

I am having a hard time doing a 'INSERT INTO' with 2 sub queries in the WHERE clause. I'm not sure wht I'm missing, it keep stating that an expression of non-boolean type specified in context where a condition is expected, near ';'.

This is my attempt at it:

INSERT INTO [Monitor].[dbo].[MonitorIncidents]
SELECT * 
FROM dbo.MonitorSource
WHERE (
    SELECT DISTINCT * 
    FROM Lookup.dbo.ServerInfo S 
    WHERE NOT EXISTS
    (
        SELECT 1  
        FROM Lookup.dbo.Facts F 
       开发者_JAVA技巧 WHERE F.FactsName = S.SrvName 
        AND W.DateTime > DATEADD(hour, -23, CURRENT_TIMESTAMP)
    )
)


Your WHERE clause is missing an operand like =,<, >, etc. You are just returning a field to WHERE wihout a comparison. Depending on what you want to do, extend your WHERE to include a comparison.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜