Reputation: 11
I've tried this query in MS Access SQL query section
create table demo(
deomid long not null identity(1,1),
name varchar(200),
primary key(userid)
)
I also have used identity , autonumber , autoincrement , autoincrement(1,1) , auto_increment
instead of identity(1,1)
in the above query.
Every statement produces error saying that syntax error in create table statement... Please tell what is proper way to auto increment a long field.
Upvotes: 0
Views: 7615
Reputation: 1
CREATE TABLE Demo
(
[USER_ID] counter PRIMARY KEY,
[NAME] varchar(200) null,
[NAME_2] varchar(150) not null,
[NUMBER] double null,
[DATE] datetime not null
)
Upvotes: 0
Reputation: 31
You can try this
CREATE TABLE EMPLOYEE
{
Emp_ID int NOT NULL IDENTITY(1,1)
}
Upvotes: 0
Reputation: 57023
The IDENTITY
keyword and any of its synonyms that involve its seed and increment values require ANSI-92 Query Mode.
Also, you can't create a PRIMARY KEY
on userid
because it isn't a valid column name. Perhaps you meant to use deomid
? Try this:
CurrentProject.Connection.Execute _
"create table demo( " & _
"deomid long not null identity(1,1), " & _
"name varchar(200), " & _
"primary key(deomid) " & _
")"
Note your table still lacks a business key i.e. to be able to identify users in the real world. I would guess there should be a UNIQUE
constraint on name
(which should probably not be nullable!)
Upvotes: 0
Reputation: 480
from here http://www.datanamic.com/support/msaccess-autoinc.html
Use the COUNTER data type when you want to define an auto increment/auto number/identity column in MS Access. The COUNTER data type provides a monotonically increasing sequence of long integers for a column in a MS Access database.
Upvotes: 0