Shows how table variables keep data even after a transaction rollback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN TRAN; | |
DECLARE @MyHoldingTable TABLE (id int NOT NULL, FirstName varchar(50) NOT NULL, LastName varchar(50) NOT NULL); | |
INSERT INTO dbo.CustomersTableIdent (FirstName, LastName) | |
OUTPUT inserted.id, inserted.FirstName, inserted.LastName | |
INTO @MyHoldingTable (id, FirstName, LastName) | |
VALUES ('My first name (removed)', 'My last name (removed)'); | |
ROLLBACK | |
SELECT id, FirstName, LastName FROM @MyHoldingTable; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment