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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Master-detail insert problem

Author  Topic 

dinub
Starting Member

3 Posts

Posted - 2008-01-08 : 14:27:21
Hello!
I have an aplication (in visual foxpro) running on a sql server database.
When I want to save data from a master detail form I do the following:
- save the master record (insert)
- query database to get the "id" (identity(1,1) using
select ident_current('table_name')
- put the master id in the link field of details
- save the details (insert).
Things went ok until heavy ussage occured, on the same form(table).
I got few details that were linked to wrong masters probably because another master was inserted before the previous query for id occured.
Can someone give me some advice..

Dinu

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-01-08 : 15:06:36
Instead of this:
select ident_current('table_name')

use this after the insert:
select SCOPE_IDENTITY( )


CODO ERGO SUM
Go to Top of Page
   

- Advertisement -