guinea2
guinea2

Reputation: 185

SQL Syntax error in CREATE TABLE

I am new to Microsoft SQL Server, and I have been doing an exercise in my book. I have been doing pretty well until now... I am trying to create a table from this code, and it says syntax error in create table. I am not sure, I have did research with no luck on a solution. This is what the book says to use, but its not working... Any help will and guidance will be greatly appreciated.

CREATE  TABLE SALESPERSON
(
  NickName                   Char (35)                 NOT NULL,         
  LastName                   Char (25)                 NOT NULL,
  FirstName                  Char (25)                 NOT NULL,
  HireDate                   DateTime                  NOT NULL
  WageRate                   Numeric                   NOT NULL,
  CommissionRate             Numeric                   NOT NULL,
  Phone                      Char (12)                 NOT NULL,
  Email                      Varchar (100)             NOT NULL,

  CONSTRAINT SALESPERSON_PK PRIMARY KEY(NickName)
);

Upvotes: 0

Views: 406

Answers (2)

yogesh suhagiya
yogesh suhagiya

Reputation: 498

You forget to add comma after " HireDate DateTime NOT NULL ":

try following:

CREATE TABLE IF NOT EXISTS `SALESPERSON` (
  `NickName` char(35) NOT NULL,
  `LastName` char(25) NOT NULL,
  `FirstName` char(25) NOT NULL,
  `HireDate` datetime NOT NULL,
  `WageRate` decimal(10,0) NOT NULL,
  `CommissionRate` decimal(10,0) NOT NULL,
  `Phone` char(12) NOT NULL,
  `Email` varchar(100) NOT NULL,
  PRIMARY KEY (`NickName`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Upvotes: 0

CodeNewbie
CodeNewbie

Reputation: 2091

Assuming you didn't lose any characters while pasting your script here, I think the syntax error might be due to a missing comma here.

 HireDate DateTime NOT NULL, WageRate Numeric
                           ^

Upvotes: 2

Related Questions