With a query such as,
SET NoCount ON
INSERT INTO ....
VALUES ...
SELECT scope_identity()
SET NoCount OFF
, can I trust that the id I get back is for the row that I just inserted, or
can it be incorrect because of other "simultaneous" inserts? I need it for
an ASP page.
Thanks,
Marcus 3 10869
[posted and mailed, vänligen svara i nys]
Marcus (lu****@ludd.luth.se) writes: With a query such as,
SET NoCount ON INSERT INTO .... VALUES ... SELECT scope_identity() SET NoCount OFF
, can I trust that the id I get back is for the row that I just inserted, or can it be incorrect because of other "simultaneous" inserts? I need it for an ASP page.
800 grader, du kan lita på mej, du kan lita på mej.
Yes, you can trust it. scope_identity is local to your process - in
fact local to the scope (procedure, batch etc) you are in.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
Tack så mycket - Thank you. ;)
Marcus
"Erland Sommarskog" <so****@algonet.se> wrote in message
news:Xn*********************@127.0.0.1... [posted and mailed, vänligen svara i nys]
Marcus (lu****@ludd.luth.se) writes: With a query such as,
SET NoCount ON INSERT INTO .... VALUES ... SELECT scope_identity() SET NoCount OFF
, can I trust that the id I get back is for the row that I just inserted, or can it be incorrect because of other "simultaneous" inserts? I need it for an ASP page.
800 grader, du kan lita på mej, du kan lita på mej.
Yes, you can trust it. scope_identity is local to your process - in fact local to the scope (procedure, batch etc) you are in.
-- Erland Sommarskog, SQL Server MVP, so****@algonet.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
Tack så mycket - Thank you. ;)
Marcus
"Erland Sommarskog" <so****@algonet.se> wrote in message
news:Xn*********************@127.0.0.1... [posted and mailed, vänligen svara i nys]
Marcus (lu****@ludd.luth.se) writes: With a query such as,
SET NoCount ON INSERT INTO .... VALUES ... SELECT scope_identity() SET NoCount OFF
, can I trust that the id I get back is for the row that I just inserted, or can it be incorrect because of other "simultaneous" inserts? I need it for an ASP page.
800 grader, du kan lita på mej, du kan lita på mej.
Yes, you can trust it. scope_identity is local to your process - in fact local to the scope (procedure, batch etc) you are in.
-- Erland Sommarskog, SQL Server MVP, so****@algonet.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Scrappy |
last post by:
I have an ASP front end on SQL 2000 database. I have a form that submits to
an insert query. The entry field is an "identity" and the primary key. I
have used scope_identity() to display the...
|
by: Marko Poutiainen |
last post by:
Situation:
We had to make our SQLServer 2000 database multi-lingual. That is, certain
things (such as product names) in the database should be shown in the
language the user is using (Finnish,...
|
by: Marcus |
last post by:
With a query such as,
SET NoCount ON
INSERT INTO ....
VALUES ...
SELECT scope_identity()
SET NoCount OFF
, can I trust that the id I get back is for the row that I just inserted, or
can it...
|
by: Greg Ofiesh |
last post by:
Anyone who can help,
I have two tables T1 and T2. T1 has fields K1 and F2 and T2 has fields
K2 and F1. F1 is the foreign key relating to K1 and F2 is the foreign
key relating to K2.
My...
|
by: Larry |
last post by:
I am seeing a problem with an ASP application, where I have 2 tables.
In the first table, the ASP inserts just 1 row and retrieves the
primary key of the new row using SCOPE_IDENTITY. It then uses...
|
by: Hardy Wang |
last post by:
Hi all,
I have the following codes, but SCOPE_IDENTITY() just returns NULL to
me. If I comment out SCOPE_IDENTITY() line and run @@IDENTITY line, it works
fine!! Since I have a trigger on the...
|
by: Chad Dittmer via .NET 247 |
last post by:
I'm having problems inserting into Sql 2000 using SqlHelper.ExecuteScalar.
When it inserts, it only takes the first character from the string?? Any help would be appreciated. Here is the code and...
|
by: Bruno Alexandre |
last post by:
Hi guys,
I have a web application that insert Clients info into the Database, the
Apllication is accesed by several user at the same time, the Client Info is
divide by 3 tables (Client, Product...
|
by: Dylan Parry |
last post by:
Hi folks,
This is really confusing me. I am trying to insert a row into a
database, and then use scope_identity() to return the value of the ID
column for the record I have just created. The...
|
by: Mike |
last post by:
Sql Server, Scope_Identity(), Ado.NET:
Which is better? Using an output parameter to return Scope_Identity through
ExecuteNonQuery(), or adding Select Scope_Identity() to the end of the...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |