Solved

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

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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now