I created a new table in SQL Server 2008 R2, and i would like that the index is on autoincrement. How to do that? There is no identity data type; i selected int
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
If your table definition is like this,
change it to,
This will create an identity column which starts id with 1 and keeps increasing it by one(i.e. step) as each record in the table is inserted.
In SQL Server, it's not a separate datatype ("autoincrement") - but you can define an
INT
column to be anIDENTITY
.How are you creating your table - visual designer or T-SQL script??
In T-SQL, you would use:
and in the visual table designer, you need to check:
It's an option for a column of type INT - you can define the seed (starting value) and the increment - typically both are set to 1.