使用 Microsoft SQL Server Management Studio 2008。我做了一个简单的事务:
BEGIN TRAN
SELECT ko.ID, os.ID AS ID2
FROM table_a AS ko
JOIN table_b AS os ON os.ID=ko.ID
WHERE (ko.the_date IS NOT NULL AND os.the_date IS NULL);
UPDATE table_b SET the_date=ko.the_date
FROM table_a AS ko
JOIN table_b AS os ON os.ID=ko.ID
WHERE (ko.the_date IS NOT NULL AND os.the_date IS NULL);
SELECT ko.ID, os.ID AS ID2
FROM table_a AS ko
JOIN table_b AS os ON os.ID=ko.ID
WHERE (ko.the_date IS NOT NULL AND os.the_date IS NULL);
ROLLBACK
所以 SELECT 和 UPDATE 应该是一样的。结果应该返回 0 行。但是 UPDATE 影响的行比 SELECT 从 DB 中获得的少:
(61 行受影响)
(60 行受影响)
(0 行受影响)
我在这里想念什么?