Passing identity values outside triggers

Passing identity values outside triggers

Post by Dan Armstron » Wed, 23 Jul 1997 04:00:00



Does anybody know of a way to pass the number that an INSERT generated
with an identity column to an outside query?

For example,

If we were inserting a whole bunch of records into a table, I want to
also insert 1 record in a control table and use it's returned identity
value as a column value in my insert.

I know the following syntax is ridiculous, however it illustrates the
point:

Assume there is a trigger on the table CONTROL that returns the identity
value from the logical inserted table

INSERT INTO LOTSOFRECORDS
(CONTORLNUMBER,VALUE,WHATEVERELSE)
VALUES
((INSERT INTO CONTROL GETDATE()),myValue,WhatEverOtherValues)

            ^ This insert would generate a returned Identity column
value

Any Thoughts?

Dan.