Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Country, state list for SQL Server [closed]

Hi In a application i need to list all countries in the world , we i select a country all the states corresponding to it should be listed, if i select as state all the cities in that state should listed.

I have created the tables with references in SQL Server 2005.

I need the complete data list of countries , states, cities Is there any solution or packages or files available so that we can import to SQL Server.

like image 682
Fairy_G Avatar asked Jul 01 '10 12:07

Fairy_G


2 Answers

ISO country codes are here. You can download this in a number of formats (CSV etc) and using DTS or a similar product you ought to be able to import them into your database.

Once you get down to states or regions in countries it gets bit trickier. You may have to put these together yourself, or search for individual resources that provide them.

EDIT:

I found the US States here, in MySQL format - which you can probably easily adapt.

like image 155
Ciaran Archer Avatar answered Sep 20 '22 16:09

Ciaran Archer


As leon01 said you can use GeoNames.

I did a small tool to generate an XML file based on the output of their webservices: https://github.com/yosoyadri/GeoNames-XML-Builder

All credit should really go to the C# library at http://geonamesdotorgdotnet.codeplex.com/ that I'm using to parse the response XML from the services.

You have an already made list of countries and provinces from this service at https://raw.github.com/yosoyadri/GeoNames-XML-Builder/master/continents-countries-statesprovinces.xml

like image 44
Yosoyadri Avatar answered Sep 22 '22 16:09

Yosoyadri