Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Other SQL Server 2012 Topics
 INT KEY FILD AUTOINCREMENTAL: NO CORRECT INCREMENT

Author  Topic 

robycave
Starting Member

2 Posts

Posted - 2014-03-17 : 07:05:23

Good afternoon.
I created (into a server with IIS and SQL Server 2012 Express) a table with key field type INT and IDENTITY SPECIFICATION = YES, IDENTITY INCREMENTAL=1, IDENTITY SEED=1.
When I test it from my computer client (and the asp.net application running in the computer client, but connected to the database in the Server) the autoincremental field works well. When I copy the asp.net application into the server and I run it by server address, the key filed generate a number more upper that the same application from the Client coputer. For example: from the client my key file generate the number 22, 23, 24...and so on. Form the server it generate 1045,1046 adn so on. Why? It should generate 25, 26 and so on.

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-03-17 : 08:26:24
The next identity value generated depends on the value of IDENT_CURRENT. For reasons that I don't have enough information to comment on, the IDENT_CURRENT in your server is different. You can find the current IDENT_CURRENT using
SELECT IDENT_CURRENT('YourTableNameHere')
. When you insert a new row, the value assigned to the identity column would be the next one.

You may fine these pages useful:

http://technet.microsoft.com/en-us/library/ms175098.aspx
http://technet.microsoft.com/en-us/library/ms189834.aspx
http://technet.microsoft.com/en-us/library/ms176057.aspx
Go to Top of Page

robycave
Starting Member

2 Posts

Posted - 2014-03-18 : 05:47:21
Thank you very much James K.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2014-03-18 : 07:45:06
With SQL Server 2012, it's perfectly valid to have a jump in the identity sequence due to changes made by Microsoft.
See http://stackoverflow.com/questions/14162648/sql-server-2012-column-identity-increment-jumping-from-6-to-1000-on-7th-entry



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
   

- Advertisement -