Skip to content

Instantly share code, notes, and snippets.

@gazlu
Created October 27, 2016 14:57
Show Gist options
  • Save gazlu/2c0e55d2e9a4ac640208a2a5c3311cb7 to your computer and use it in GitHub Desktop.
Save gazlu/2c0e55d2e9a4ac640208a2a5c3311cb7 to your computer and use it in GitHub Desktop.
Insert multiple records and get the identity value
CREATE TABLE #A (ID int Identity(1,1), fn varchar(10))
DECLARE @output TABLE (id int)
Insert into #A (fn)
OUTPUT inserted.ID INTO @output
values ('1'), ('2'), ('3')
select * from @output
DROP TABLE #A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment