I am writing a stored procedure to process a table belonging to an application and insert values into a table belonging to the same application (so I cannot amend either tab
I know this question is nearly a year old, but your insert can work as you have presented it if you select the proper column name from the OUTPUT
The output clause gives us one of two possible virtual tables, inserted or deleted, depending on the operation, an update operation gives both. Since you don't have a field name DET_DATE in your TRN_TEMP table that you just inserted into, it is invalid in the output statement.
INSERT INTO TRN_TEMP (TRN_TRAN_DATE, TRN_DESCRIPTION, TRN_AMT)
OUTPUT INSERTED.TRN_TRAN_DATE, GETDATE()
INTO REGISTER (DET_PRIMARY_LINK, INS_DATE)
SELECT D.DET_DATE, 'SOMETEXT', SUM(D.DET_NET)
FROM DETAIL D
LEFT JOIN REGISTER R ON D.DET_PRIMARY = R.DET_PRIMARY_LINK
WHERE AND R.LINE_ID IS NULL -- TO REMOVE LINES ALREADY PROCESSED
GROUP BY D.DET_DATE