My normal process for inserting into one table and then getting the ID back so that I can insert into another table is like this in MSSQL:
DECLARE @transacti
Here is a quick solution for MSSQL. It uses the SCOPE_IDENTITY() function that returns the ID of the last row inserted in the previous insert statement.
http://msdn.microsoft.com/en-us/library/ms190315.aspx
DECLARE @iNewGeneratedID INT
INSERT INTO transactions
(
transactionDate,
transactionAmount
)
VALUES
(
,
)
SET @iNewGeneratedID = SCOPE_IDENTITY()
INSERT INTO transactionItems
(
transactionID,
itemID,
itemAmount
)
VALUES
(
@iNewGeneratedID,
,
)
SELECT @iNewGeneratedID AS iNewGeneratedID