I’m trying to create a bunch of entries in a database with a single script and the problem I’m encountering is how to reference the generated primary key of the previous entry I created.
For example if I created a customer, then tried to create an order for that customer, how do I get the primary key generated for the customer?
I’m using SQLServer.
Like so:
EDIT:
Apparently it needs to be SCOPE_IDENTITY() in order to function as expected with triggers.