Skip to content

Instantly share code, notes, and snippets.

Created April 13, 2018 09:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Shows how table variables keep data even after a transaction rollback
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.FirstName, inserted.LastName
INTO @MyHoldingTable (id, FirstName, LastName)
VALUES ('My first name (removed)', 'My last name (removed)');
SELECT id, FirstName, LastName FROM @MyHoldingTable;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment