Solved

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

Posted on 1998-06-23
1
174 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
1 Comment
 
LVL 7

Accepted Solution

by:
spiridonov earned 20 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

809 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