Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Is @@IDENTITY specific to a userID or to a session ?

Posted on 1998-06-23
1
Medium Priority
?
190 Views
Last Modified: 2010-03-19
I have several kiosks connecting to a database using the same user id. Each kiosk creates records to a certain table in which there is an identity field.  I wish to retrieve the value using SELECT @@IDENTITY.  If Kiosk A inserts a record then Kiosk B inserts one before I send the SELECT @@IDENTITY from Kiosk A, which identity will I get. In other words, does MS-SQL keeps a value for each session (connection) or for each user id.
0
Comment
Question by:ymailhot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
Victor Spiridonov earned 80 total points
ID: 1091614
It does it for each session. You can easily test that. Open SQL Enterprise manage.
Open  two Query windows.  
Create table tt (id int identity,test char(1))
 Execute from window1 insert into ss (test ) Values ('t')
Execute from window2 insert into ss (test ) Values ('w')
Execute from window1 SELECT @@IDENTITY : returns 1
Execute from window1 SELECT @@IDENTITY : returns 2

0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question