0

I'm creating a simple table and i'm not able to use the reserved keyword Password. I tried using backticks, but get an error

"Msg 102, Level 15, State 1, Line 7 Incorrect syntax near '`'."

I don't wanna use double quotes, can someone please tell me how to get this backtick thing working.

CREATE TABLE Users (
    NTID                VARCHAR(20)         PRIMARY KEY,
    FirstName           VARCHAR(50)         NOT NULL,
    MiddleI             CHAR(1),
    LastName            VARCHAR(50)         NOT NULL,
    EmailAddress        VARCHAR(100)        UNIQUE,
    `Password`          VARCHAR(50)     
);
Ravinder Reddy
  • 23,692
  • 6
  • 52
  • 82
rbk
  • 283
  • 2
  • 3
  • 16
  • Another clue that you are not using MySQL: `UNIQUE` cannot be placed inline with a column. The `UNIQUE KEY` syntax is supported by MySQL only as a table-level constraint. – Bill Karwin Mar 20 '14 at 17:51

1 Answers1

6

reading your error message, it seems that you are using SQL Server, not MySQL.

You need to use [] to escape reserved keywords.

CREATE TABLE Users (
    NTID                VARCHAR(20)         PRIMARY KEY,
    FirstName           VARCHAR(50)         NOT NULL,
    MiddleI             CHAR(1),
    LastName            VARCHAR(50)         NOT NULL,
    EmailAddress        VARCHAR(100)        UNIQUE,
    [Password]          VARCHAR(50)     
);
John Woo
  • 258,903
  • 69
  • 498
  • 492