0
[Table1 Columns: Server, Site, App_Name]
[Table2 Columns: Event, Server, Site, App_Name]


INSERT INTO Table2 Values(Server, Site, App_Name)
SELECT * FROM Table2 WHERE Site IN ('ABC');
UPDATE Table2 SET Event = 'XYZ' WHERE Site IS NOT NULL;

我想为在 query1 中创建的所有行设置相同的事件值。如果我确实更新,它会破坏一些以前的数据。如何将第二个查询作为 INSERT 的一部分?

4

1 回答 1

0

试试这个..

    INSERT INTO Table2 Values(Server, Site, App_Name)
SELECT Server,'XYZ',App_Name FROM Table2 WHERE Site IN ('ABC');
于 2012-05-29T07:30:07.573 回答