johnson1
asked on
insert get identity - does not return correct number
Hello,
I have a table with identity column (Id). I.e. MyTable(Id int, MyNum int, MyText varchar(50), CreatedBy int)
I insert into it like this MyTable(MyNum, MyText)values(3,'Mm')
Then I want to get the identity of the newest column. I do it like this:
SELECT @@Identity.
The newest number in the identity column is 20993, but I get returned 1005.
I do not understand why this is. Can somebody please help.
I have a table with identity column (Id). I.e. MyTable(Id int, MyNum int, MyText varchar(50), CreatedBy int)
I insert into it like this MyTable(MyNum, MyText)values(3,'Mm')
Then I want to get the identity of the newest column. I do it like this:
SELECT @@Identity.
The newest number in the identity column is 20993, but I get returned 1005.
I do not understand why this is. Can somebody please help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much. There was a trigger.
id int
)
INSERT INTO MyTable(MyNum, MyText) OUTPUT INSERTED.$IDENTITY INTO @identity values(3,'Mm')