rgb192
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'.
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'.
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= @@CHARACTE R_SET_CLIE NT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS =@@CHARACT ER_SET_RES ULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION= @@COLLATIO N_CONNECTI ON */;
/*!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';
-- 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
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=
/*!40101 SET @OLD_CHARACTER_SET_RESULTS
/*!40101 SET @OLD_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?
ASKER
i think this is mysql
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
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