Solved

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

Posted on 1998-06-23
1
169 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Creating SQL script using SQL data and SQL script 8 35
2016 SQL Licensing 7 40
Get the latest status 8 30
what are the unique tables in SQL master database 5 58
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

775 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