0

I got the error like this:

server version for the right syntax to use near 'Before INTEGER, PRIMARY KEY (ID), )' at line 8

CREATE TABLE PatientPX (
  ID INTEGER NOT NULL, 
  PXDate DATETIME, 
  PatientID INTEGER, 
  PatientPXCategoryId INTEGER, 
  FileName VARCHAR(255), 
  PXName VARCHAR(255), 
  Before INTEGER, 
  PRIMARY KEY (ID),
)
Pedigree
  • 2,384
  • 3
  • 23
  • 28
  • What version of SQL Server you are using? [It should work fine](http://www.sqlfiddle.com/#!3/5bf39). – Mahmoud Gamal Feb 18 '13 at 09:06
  • It looks like a mysql error, not mssql (which the sqlfiddle confirms when run against mysql). Please use the correct tags when asking questions, as well as the full error message. You've only got half, there. This question is highly unlikely to help *anyone else* without it. – J. Steen Feb 18 '13 at 09:09
  • btw, you have comma after primary key (id), <-- that should be removed also :) – iiro Feb 18 '13 at 09:50

3 Answers3

2

i think it's MySQL not SQL Server and in mysql, BEFORE is a reserved keyword.

CREATE TABLE PatientPX 
(
  ID INT NOT NULL, 
  PXDate DATETIME, 
  PatientID INT, 
  PatientPXCategoryId INT, 
  FileName VARCHAR(255), 
  PXName VARCHAR(255), 
  `Before` INT, 
  PRIMARY KEY (ID),
)

but I'd rather avoid name that are on reserved keywords as it will give problem if names where not properly handled.

Pedigree
  • 2,384
  • 3
  • 23
  • 28
0

Before is a keyword(mainly using in pl/sql triggers). So use another column name. Don't use any keywords.

Parvathy
  • 2,275
  • 3
  • 24
  • 39
0

It does look like MySQL rather than MS SQL ... however I believe "before" is a reserved word ... therefore it cannot be used for a column name.

http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

Table 9.2. Reserved Words in MySQL 5.0.96

Daves_War
  • 164
  • 3