?
Solved

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

Posted on 1998-06-23
1
Medium Priority
?
184 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:
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
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.
Suggested Courses

777 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