I am using a stored procedure to insert data into a database, when it is inserted it is automatically given a ID that is an identity, it also the Primary Key of the table. I also need to insert data into a second table of which that ID is one of the columns that needs to be inserted. But it the ID hasnt been created yet, so I was wondering how would you guys go about solving this problem. I need it so when they submit my form that it inserts the user, and then I need to add it to a table that basically will document that user being created. Is this possible.? I am using Microsoft SQL Server 2005.
Thanks
You can look at what @@IDENTITY, SCOPE_IDENTITY(), and IDENT_CURRENT to see which one will fit your needs best. I suspect SCOPE_IDENTITY will do the job.
Here is a good article on what they all do.