Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
supersql
Yak Posting Veteran
99 Posts |
Posted - 2005-09-20 : 08:06:02
|
| HII have made relationships between tables through IDENTITY columns, now I want to carry over the IDENTITY values to the child tables when new rows are inserted into the parent table.Right now I am using IDENT_CURRENT(parent tablename) but from this I am just getting the Identity value of the last inserted row from the parent table.What I need is Identity values of the all the rows inserted in the previous transaction from the parent table.Is there a way to do this? |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-09-21 : 00:02:05
|
| You should be using SCOPE_IDENTITY() to get the last identity value you inserted. You might consider using a batch number for these inserts. Have a table that produces one "batch ID" and a datetime for each batch. You can then insert the batch_id into the parent table. When you need to populate the children, you pull all primary keys with the appropriate batch number.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
supersql
Yak Posting Veteran
99 Posts |
Posted - 2005-09-21 : 08:02:41
|
| DerrickI understand tht we can use SCOPE IDENTITY and it gives only the last identity value from the parent table but what I need is all the Identity values tht are generated from the last insertion. |
 |
|
|
|
|
|