@@IDENTITY returning incorrect value

@@IDENTITY returning incorrect value

Post by Nabeel Moee » Fri, 19 Apr 2002 17:16:33



Hello All,



'return' is used to return the error code ).

All the procedures are working fine.. except for one which always returns a
value 2 greater than the actual identity of the row inserted.

e.g. if the procedure returns 82.. the actual identity for the row inserted

identity is 83.

What could be the cause and how do i correct this behavior??

thanx

 
 
 

@@IDENTITY returning incorrect value

Post by Nabeel Moee » Fri, 19 Apr 2002 17:13:20


Hello All,



'return' is used to return the error code ).

All the procedures are working fine.. except for one which always returns a
value 2 greater than the actual identity of the row inserted.

e.g. if the procedure returns 82.. the actual identity for the row inserted

identity is 81.

What could be the cause and how do i correct this behavior??

thanx

 
 
 

@@IDENTITY returning incorrect value

Post by Tibor Karasz » Fri, 19 Apr 2002 16:24:53


Perhaps there's a trigger on the table in which you INSERT to and that trigger has an insert as
well? If you are on SQL2K, use SCOPE_IDENTITY instead. If on 7.0, search KB as there's an
article on the subject.

--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sql...


> Hello All,


> the stored procedure i'm using to insert data into a table should return the

> 'return' is used to return the error code ).

> All the procedures are working fine.. except for one which always returns a
> value 2 greater than the actual identity of the row inserted.

> e.g. if the procedure returns 82.. the actual identity for the row inserted

> identity is 81.

> What could be the cause and how do i correct this behavior??

> thanx

 
 
 

@@IDENTITY returning incorrect value

Post by Paresh Chobhe[M » Mon, 22 Apr 2002 12:31:32


Nabeel,

What version of SQL Server are you running? Could you send the part of the

Thanks,

Paresh Chobhe

The posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Strategic Technology Protection
Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

--------------------


| Date: Thu, 18 Apr 2002 13:16:33 +0500
| Lines: 23
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

| Newsgroups: microsoft.public.sqlserver.programming
| NNTP-Posting-Host: 202.125.137.179
| Path: cpmsftngxa08!cpmsftngxa07!tkmsftngp01!tkmsftngp07
| Xref: cpmsftngxa08 microsoft.public.sqlserver.programming:251464
| X-Tomcat-NG: microsoft.public.sqlserver.programming
|
| Hello All,
|

|
| the stored procedure i'm using to insert data into a table should return
the

and
| 'return' is used to return the error code ).
|
| All the procedures are working fine.. except for one which always returns
a
| value 2 greater than the actual identity of the row inserted.
|
| e.g. if the procedure returns 82.. the actual identity for the row
inserted

| identity is 83.
|
| What could be the cause and how do i correct this behavior??
|
| thanx
|
|
|
|
|
|

 
 
 

1. SQL6.5 - @@Identity Returns Incorrect Values

Can anyone help?


variable after an insert it constantly returns the wrong value

eg I get 17640 instead of 1.

The right value is inserted into the table but causes problems with FK
constraints

I have tried:-
1. DBCC CheckIdent.
2. Truncating the table (with and without checkpointing)
3. Dropping and recreating the table
4. Stopping & starting the Server

All with no success.

Thanks

Toby

2. Examination

3. Incorrect Identity value

4. Export Table Definition and Data?

5. dbcc dbreindex

6. OLE DB provider MSDASQL returned an incorrect value for DBPROP_CONCATNULLBEHAVIOR w/ OPENROWSET

7. Pls help with case sensetive check for = operator

8. OLE DB provider MSDASQL returned an incorrect value for DBPROP_CONCATNULLBEHAVIOR

9. ODBC returns incorrect value in stored procedure

10. ODBC call stored procedure returns incorrect value

11. ODBC return incorrect value

12. Float field sum returning incorrect value ?