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)
 How to obtain the Identity value for a master-detail insertion, in a shared connection environment?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-10-17 : 16:54:11
Victor writes "I'm developing a web system with IIS4 - ASP - ODBC - SQL Server 6.5.

I need to insert a record in a table and immediatly insert other values in its corresponding detail (child) table.

I read about the @@identity global variable and I found a procedure in Microsoft K-B based in the utilization of @@identity and @@spid saved in a temporary table.

But I also read that this procedure isn't valid in a shared connection environment (the users of my web application uses a unique system DSN in the server to connect to the SQL database), because many user can perform inserts based in the same SPID. Then I think about the utilization of the thread Id, but I don't know how implement it.

How can I obtain the current spid and thread ID in this scenario?"
   

- Advertisement -