开发者

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

开发者 https://www.devze.com 2023-03-21 01:15 出处:网络
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

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

精彩评论

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