AutoNumber() ("M" Reference)
[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the Model Citizen blog.]
This function causes the SQL identity attribute to be applied to a primary key field. The result is that each time a new row is entered in the table, the value of the key is incremented by one, thus ensuring a unique value.
Example
The following example uses the AutoNumber()
function to generate a T-SQL bigint
identity field.
module Northwind {
type Employee
{
Id : Integer64 = AutoNumber();
} where identity(Id);
Employees : Employee;
}
The preceding code generates the following T-SQL code when compiled.
create table [Northwind].[Employees]
(
[Id] bigint not null identity,
constraint [PK_Employees] primary key clustered ([Id])
);