Getting new IDs after insert

前端 未结 4 1795
我在风中等你
我在风中等你 2020-12-07 16:46

I\'m inserting a bunch of new rows into a table which is defined as follows:

CREATE TABLE [sometable](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [someval] s         


        
4条回答
  •  失恋的感觉
    2020-12-07 17:21

    create a table to set all the new IDs. then make a loop for all the insert. inside the loop make the insert you want with SCOPE_IDENTITY(). after the insert get the new ID and insert it into the new table you created for. in the end select * from [newTable].

提交回复
热议问题