【发布时间】:2017-03-02 14:41:27
【问题描述】:
ID Date Time Status UserID
1 2017-02-23 19:30:00.0000000 1 130
2 2017-02-23 20:00:00.0000000 0 130
上表是一个#temptable。这是在不同的时间间隔执行的。所以在执行时,前2行插入到下表中
Date Time Status
2017-02-23 19:30:00.0000000 1
2017-02-23 20:00:00.0000000 0
然后执行,1行添加到#temptable如下。
ID Date Time Status UserID
1 2017-02-23 19:30:00.0000000 1 130
2 2017-02-23 20:00:00.0000000 0 130
3 2017-02-23 23:30:00.0000000 1 130
所以我需要将 #temptable 中的新行插入到下表中,而该表不在下表中
Date Time Status
2017-02-23 19:30:00.0000000 1
2017-02-23 20:00:00.0000000 0
【问题讨论】:
-
尝试使用“except”...msdn.microsoft.com/en-us/library/ms188055.aspx
标签: sql sql-server stored-procedures temp-tables