To preface, I have to do a bulk insert in a patients table that looks similar to:
pid     | FirstName       | LastName
-------------------------------------------
10     | John             | Cena
11     | Eric             | Bischoff
12     | Vince            | Russo
My insert statement looks something like:
INSERT INTO patients (FirstName, LastName) 
OUTPUT inserted.pid
VALUES ('Seth', Rollins');
This returns the latest pid, but how would I use that returned identity in another insert statement in a completely different table?
INSERT INTO booking (pid, start, end) 
VALUES (inserted.pid, 'XX/XX/XXXX', XX/XX/XXXX');
IE:
booking_id | pid   | start       | end 
-----------------------------------------
1          | 10    | 08/01/2016  | NULL
2          | 11    | 07/25/2016  | 07/26/2016
I am looping through a large .csv file with this first and last name information.
 
     
     
    