I'm looking at my SQL code in Microsoft Access and I see nothing wrong. I try to run the query and it says "syntax error in create table statement."
CREATE TABLE Authors
(
Au_Num INT (3) PRIMARY KEYA,
Au_LName VARCHAR (10) NOT NULL,
Au_FName VARCHAR (10),
Book_Number INT (2),
Client_Name VARCHAR (20)
);
Solution 1:
Removing the parenthesized numbers from INT declarations works:
CREATE table Authors (
Au_Num INT Primary Key,
Au_LName VARCHAR(10) NOT NULL,
Au_FName VARCHAR(10),
Book_Number Int,
Client_Name VARCHAR(20)
);
If the primary key should be an autonumber:
CREATE table Authors (
Au_Num AUTOINCREMENT Primary Key,
Au_LName VARCHAR(10) NOT NULL,
Au_FName VARCHAR(10),
Book_Number Int,
Client_Name VARCHAR(20)
);
Solution 2:
Data types such as int, bigint, datetime, smallint, tinyint, bit, bool and date has predefined length, hence it is not required to specify the length explicitly.
Remove the length for int data types
create table Authors (
Au_Num INT Primary Key,
Au_LName VARCHAR (10) NOT NULL,
Au_FName VARCHAR (10),
Book_Number Int,
Client_Name VARCHAR (20)
);