create table test(id int identity(1,1),code int)
goinsert into test select 1
select @@identityinsert into test select 1
select @@identityselect * from test
godrop table test
go
goinsert into test select 1
select @@identityinsert into test select 1
select @@identityselect * from test
godrop table test
go
DECLARE @iden2 INT
INSERT INTO
select @iden1=@@identity --第一个
INSERT INTO
select @iden2=@@identity --第二个PRINT @iden1
PRINT @iden2