Well, I have two tables:
CREATE TABLE Temp(
TEMP_ID int IDENTITY(1,1) NOT NULL, ... )
CREATE TABLE TEMP1(
TEMP1_ID int IDENTITY(1,1) NOT NULL,
TEMP_ID int, ... )
they are linked with TEMP_ID foreign key. In a stored procedure I need to create tons of Temp and Temp1 rows and update them, so I created a table variable (@TEMP) and I am dealing with it and finally make one big INSERT into Temp. My question is: how can I fill @Temp with correct TEMP_ID's without insert safely from multiple sessions?