SQL AutoIncrement

Using AutoIncrement in Dynamics NAV is an alternative to using Number Series or calculating new number based on a FINDLAST on the Record you are about to insert into.

There can only be one AutoIncrement field in a Table.
You must be member of db_owner on the database in SQL to set the AutoIncrement property.
Autoincrement does not work on Temp Tables
When inserting records into a table with an AutoIncrement field, the field is not assign a value, and if visible in Page, it should not be editable.
Always count up (handled by SQL)
No tablelock because of Numberseries.
No FINDLAST to calculate new number.
If a transaction is rolled back, the number is NOT reused. (not always important)

Lets create a AutoIncrement field:
Create a field of datatype Integer og BigInteger.
Set the AutoIncrement property to YES.
Assign 0 to the field in OnInsert();


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s