Showing posts with label cities. Show all posts
Showing posts with label cities. Show all posts

Thursday, December 11, 2014

List of cities as SQL inserts

There are times you might need a list of cities as SQL inserts.
For this reason I extracted quite a large list of cities from MaxMind database.
The list is composed of 2 columns:
  • Country code as ISO-3166 alpha2 (2 letters for each country)
  • City name
There is also a script that creates the cities table (SQL Server syntax):

 CREATE TABLE [dbo].[city](  
      [country_code] [char](2) NOT NULL,  
      [city] [varchar](100) NOT NULL,  
  CONSTRAINT [PK_city] PRIMARY KEY CLUSTERED   
 (  
      [country_code] ASC,  
      [city] ASC  
 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]  
 ) ON [PRIMARY]  

DOWNLOAD: You can download the list of cities HERE