122 questions
-1 votes
1 answer
59 views
Only shows NULL when using the variable which set with Scope_Identity() on JOIN statements in a stored procedure
After INSERT and setting a variable (@scopeID) with SCOPE_IDENTITY(), when I try to JOIN tables with @scopeID, I can only see the value of @scopeID, and other variables are NULL. INSERT INTO ...
0 votes
0 answers
351 views
Using Select Scope_Identity() in a stored procedure without an output variable [duplicate]
I am trying to utilize a vendors stored procedure that I cannot change. In C# I need the Scope_Identity value. If I could I would set @ID as an output variable. Running the procedure in SQL Developer ...
1 vote
0 answers
1k views
Value of SCOPE_IDENTITY() when inserting more than one row
The documentation for SCOPE_IDENTITY states that it Returns the last identity value inserted into an identity column in the same scope. I wonder what last really means. Is it the largest value ...
-3 votes
1 answer
733 views
Scope_identity is giving null values? [closed]
I have stored procedure in which I use scope_identity() Create table table1 id int, name varchar, age int Create procedure details @id int, @name varchar, age int ...
-1 votes
2 answers
330 views
SCOPE_IDENTITY returns null until an error is thrown in MS Access
MS Access front-end with a SQL Server back-end, using pass-through queries in Access over OBDC connection. No ADO, just simple DAO query objects. After an INSERT query is executed, a "SELECT ...
0 votes
0 answers
16 views
How to use scope_identity in jdbc [duplicate]
How to use scope_identity in JDBC? I have to insert one table (which is in SQL Server ) primary key value into another table which is using first table primary key as foreign key.
0 votes
0 answers
57 views
PHP insert and get scope identity [duplicate]
im using PHP and SQL Server i have 2 tables: 1. user (Id_user, user_name) 2. purchase (Id_purchase, Id_user, description) i want to in insert into "user" and then insert into "purchase" with the same ...
2 votes
1 answer
353 views
Correct way/location to use Scope_Identity()
I have an auto incrementing ID called deviceID in one of my fields. I was wanting to pass this to a session in php to use later on and was planning on using scope_identity() as I understand that this ...
1 vote
0 answers
68 views
Trouble Getting Output Parameter from sp_executesql with input Parameters
I am inserting a row into a remote MS SQL server and want to to retrieve the inserted row ID. I am using sp_executesql and passing in input parameters. The row is inserting but the OUTPUT parameter is ...
2 votes
2 answers
108 views
Trying to use "Scope_Identify()" in a stored procedure from a method in a C# class to get the ID of the resultant insert
I have a stored procedure for inserting a record in a table. I'm trying to use Scope_Identity() to get back the created ID value. I call the procedure from a method named Add_Claimant(). The method ...
-2 votes
2 answers
545 views
SQL Server equivalent for Oracle IDENTITY_VAL_LOCAL() function
I am in the middle of a project where we are moving from Oracle to SQL Server. I was wondering if, like the title says,there are any SQL Server equivalent for Oracle's built in function ...
0 votes
1 answer
326 views
ADO.NET SqlCommand not returning correct value for SCOPE_IDENTITY()
I have a simple table : CREATE TABLE [MyTable] ( [ID] [INT] IDENTITY(1,1) NOT NULL, [NAME] [NVARCHAR](100) NOT NULL, [DATA] [NVARCHAR](max) NOT NULL, CONSTRAINT [PK_MyTable] ...
0 votes
2 answers
1k views
SELECT SCOPE_IDENTITY() to return the last inserted ID
There are a few answers about this problem, but my question is about the particular code I have. I'm trying to get the last inserted ID of this query executing on VBA code. Public Function Execute(...
0 votes
1 answer
1k views
SCOPE_IDENTITY() is returning NULL instead of expected value
With Python and SQL Server, I am inserting a row into table. Post record insertion, I am using SCOPE_IDENTITY() to get latest ID for inserted record. Instead of receiving expected ID, the function is ...
0 votes
0 answers
153 views
Determine UniqueIdentifier id of newly created record in remote table
When I create a new record in a table that has a primary key of type INT and I want to retrieve the value of its ID, I use something like this: INSERT INTO MyTable (Fields) VALUES (MyValues); ...