Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

Incorrect syntax near the keyword 'KEY'.

CREATE TABLE uk_postcodes (
  postcode varchar(5) NOT NULL,
  x int(11) NOT NULL DEFAULT '0',
  y int(11) NOT NULL DEFAULT '0',
  latitude decimal(5,2) NOT NULL DEFAULT '0.00',
  longitude char(8) NOT NULL DEFAULT '0',
  town varchar(255) DEFAULT NULL,
  county varchar(255) DEFAULT NULL,
  PRIMARY KEY (postcode),
  KEY x (x,y)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='DanielGibbs.Net Free UK Postcode Database';



Msg 156, Level 15, State 1, Line 10
Incorrect syntax near the keyword 'KEY'.
Avatar of dwkor
dwkor
Flag of United States of America image

CREATE TABLE uk_postcodes (
  postcode varchar(5) NOT NULL,
  x int NOT NULL DEFAULT 0,
  y int NOT NULL DEFAULT 0,
  latitude decimal(5,2) NOT NULL DEFAULT 0,
  longitude char(8) NOT NULL DEFAULT 0,
  town varchar(255) DEFAULT NULL,
  county varchar(255) DEFAULT NULL,

  PRIMARY KEY (postcode)
)

What exactly is the key? Is it unique index? use: create unique index IDX_UK_PostCodes on uk_postcodes(X,Y)

I would also consider to change type of postcode column from varchar(5) to char(5) if all values are 5 digits
Avatar of rgb192

ASKER

i dont know what the key is



-- Generation Time: May 14, 2010 at 06:58 PM
-- Server version: 5.1.41
-- PHP Version: 5.3.1

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

-- Table structure for table `uk_postcodes`

CREATE TABLE IF NOT EXISTS `uk_postcodes` (
  `postcode` varchar(5) NOT NULL,
  `x` int(11) NOT NULL DEFAULT '0',
  `y` int(11) NOT NULL DEFAULT '0',
  `latitude` decimal(5,2) NOT NULL DEFAULT '0.00',
  `longitude` char(8) NOT NULL DEFAULT '0',
  `town` varchar(255) DEFAULT NULL,
  `county` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`postcode`),
  KEY `x` (`x`,`y`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='DanielGibbs.Net Free UK Postcode Database';
This is for sure not T-SQL syntax. What are you trying to do? Port the system to mssql?
Avatar of rgb192

ASKER

i think this is mysql

Avatar of rgb192

ASKER

want to create this database in sqlserver 2005
If you want to create this table in SQL Server database, you can use the syntax from my first post.
ASKER CERTIFIED SOLUTION
Avatar of dportas
dportas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

thanks