declare @a TABLE(id INT)
BEGIN TRANSACTION
INSERT @a (id) VALUES(1)
save transaction a
INSERT @a (id) VALUES(2)
save transaction b
INSERT @a (id) VALUES(3)
rollback transaction a
COMMIT
SELECT * FROM @a
/*
id
-----------
1
2
3
(3 行受影响)
*/
create TABLE #a(id INT)
BEGIN TRANSACTION
INSERT #a (id) VALUES(1)
save transaction a
INSERT #a (id) VALUES(2)
save transaction b
INSERT #a (id) VALUES(3)
rollback transaction a
COMMIT
SELECT * FROM #a
DROP TABLE #a
/*
id
-----------
1
(1 行受影响)
*/
declare @a TABLE(id INT)
BEGIN TRANSACTION
INSERT @a (id) VALUES(1)
save transaction a
INSERT @a (id) VALUES(2)
save transaction b
INSERT @a (id) VALUES(3)
rollback transaction b
COMMIT
SELECT * FROM @a
/*
id
-----------
1
2
3
(3 行受影响)
*/
create TABLE #a(id INT)
BEGIN TRANSACTION
INSERT #a (id) VALUES(1)
save transaction a
INSERT #a (id) VALUES(2)
save transaction b
INSERT #a (id) VALUES(3)
rollback transaction b
COMMIT
SELECT * FROM #a
DROP TABLE #a
/*
id
-----------
1
2
(2 行受影响)
*/