WPFKK
WPFKK

Reputation: 1477

Access sql for create table with autonumber

I am trying to create a table with a column whose AutoIncrement is Yes. Here is my query not sure what's wrong in it

CREATE TABLE testallcols(SOCycle Text(3),   AutoKey integer AUTOINCREMENT  NOT NULL, SOData LongBinary   NOT NULL)

How do I get my AutoKey column to be an auto increment integer?

Upvotes: 5

Views: 9891

Answers (2)

William M. Ramirez
William M. Ramirez

Reputation: 281

CREATE TABLE Tblcontacts ( contactid AUTOINCREMENT(101,1) PRIMARY KEY , firstname CHAR (60), lastname CHAR (60), email VARCHAR (75) );

Upvotes: -1

HansUp
HansUp

Reputation: 97101

AUTOINCREMENT and integer are two different datatypes as far as Access DDL is concerned. Use only AUTOINCREMENT. And to make it function correctly as an autonumber, include the PRIMARY KEY constraint.

This one works without error when tested with ADO/OleDb in Access 2010:

CREATE TABLE testallcols(SOCycle Text(3), AutoKey AUTOINCREMENT PRIMARY KEY, SOData LongBinary NOT NULL)

Upvotes: 8

Related Questions