My database includes a parent table by having an auto-incrementing primary key identity 'ID', along with a normal 'TIMESTAMP column'. I've child tables having a foreign key that make reference to parents 'ID' column.

I wish to write a saved method that card inserts a brand new column into both parent and child databases. Wouldso would I set the kid 'ID' column to equal the brand new auto-incremented parent 'ID' column? Performs this need a separate:

SELECT TOP 1 * FROM PARENT_TABLE

Or perhaps is there one other way?

You are able to retrieve it from SCOPE_IDENITY(). For instance:

declare @myid int
INSERT INTO table (field) VALUES ('value')
SELECT @myid = SCOPE_IDENTITY()

choose scope_identity()