Hi all,
I usually don't ask such general questions, but I'm having trouble finding anything useful on the web - so here goes.
I have a user control that inserts a record into an MSSQL database. After inserting the record, I need to insert a second record (into a different table). The second record needs to contain the ID of the first record as one of its fields.
So my question is, what is the best way to find out the id of the first record when it is inserted? Is there a way to have the stored procedure for the first insertion return the id of the record it just inserted?
I'd rather not make a select statement using all of the parameters to return the id, because there may be duplicate records.
Thanks in advance,
T
I usually don't ask such general questions, but I'm having trouble finding anything useful on the web - so here goes.
I have a user control that inserts a record into an MSSQL database. After inserting the record, I need to insert a second record (into a different table). The second record needs to contain the ID of the first record as one of its fields.
So my question is, what is the best way to find out the id of the first record when it is inserted? Is there a way to have the stored procedure for the first insertion return the id of the record it just inserted?
I'd rather not make a select statement using all of the parameters to return the id, because there may be duplicate records.
Thanks in advance,
T