Tuesday, March 20, 2012

a typical proublem related with auto generated id

hi
I am really stuck up with this problem
here is my problems
I am inserting data in 3 tables in a stored procedure
I have a table A with a auto generated id let ID
and I have updated the table A with new record (with ID)
now I have to make use of this id in the corresponding update in table B & C
in the same stored procedure
now how I can get this ID avail for the tables B and C.
one solution is to use max of the ids generated but this doesnt going to
work in case of multiple updated like a lot of users are making the updates
on the database. I am using SQL Server 2000 as DB.
please suggest me any solution
Regards
Bala
Have a look at the @.@.IDENTITY and SCOPE_IDENTITY() functions in Books on
Line.
Regards
Barry McAuslin
Look inside your SQL Server files with SQL File Explorer.
Go to http://www.sqlfe.com for more information.
"bala" <bala_at_web@.yahoo.com> wrote in message
news:u7cv2AP3EHA.1408@.TK2MSFTNGP10.phx.gbl...
> hi
> I am really stuck up with this problem
> here is my problems
> I am inserting data in 3 tables in a stored procedure
> I have a table A with a auto generated id let ID
> and I have updated the table A with new record (with ID)
> now I have to make use of this id in the corresponding update in table B &
C
> in the same stored procedure
> now how I can get this ID avail for the tables B and C.
> one solution is to use max of the ids generated but this doesnt going to
> work in case of multiple updated like a lot of users are making the
updates
> on the database. I am using SQL Server 2000 as DB.
> please suggest me any solution
> Regards
> Bala
>
|||bala wrote:
> hi
> I am really stuck up with this problem
> here is my problems
> I am inserting data in 3 tables in a stored procedure
> I have a table A with a auto generated id let ID
> and I have updated the table A with new record (with ID)
> now I have to make use of this id in the corresponding update in
> table B & C in the same stored procedure
> now how I can get this ID avail for the tables B and C.
> one solution is to use max of the ids generated but this doesnt going
> to work in case of multiple updated like a lot of users are making
> the updates on the database. I am using SQL Server 2000 as DB.
> please suggest me any solution
> Regards
> Bala
Please don't multi-post. See my comments in the other NG.
David Gugick
Imceda Software
www.imceda.com

No comments:

Post a Comment