当我们插入一行记录时,我们可以用function:SCOPE_IDENTITY() 得到
可是当我们插入一组数据时,如果想得到这一组插入数据的idntity值时,可以通过下面的SQL得得到:
DECLARE @TMP TABLE(ID INT, name char(10) ) declare @test1 table( id int identity primary key , name char(10) ) insert @test1 output inserted.* into @TMP select a.name from ( select 'angelia1' as name union all select 'angelia2' as name union all select 'angelia3' as name ) a select * from @test1 select * --, ROW_NUMBER() over ( order by id ) as num from @TMP