I'm trying to do two INSERTs as a transaction and the catch is that the auto-generated Identifier, which is the Primary Key of the first table INSERTed into, needs to be a parameter to the 2nd INSERT. After the 1st INSERT I:
SET @TripID = @@IDENTIFER
to retrieve this value, but when I use @TripID in the 2nd INSERT I get an error that this variable is NULL and I'm trying to INSERT a NULL value into a non-NULLable field. I'm thinking that this is because the 1st INSERT has not actually been executed, since it's part of a transaction that has not been committed. How can I solve this problem?
SET @TripID = @@IDENTIFER
to retrieve this value, but when I use @TripID in the 2nd INSERT I get an error that this variable is NULL and I'm trying to INSERT a NULL value into a non-NULLable field. I'm thinking that this is because the 1st INSERT has not actually been executed, since it's part of a transaction that has not been committed. How can I solve this problem?