Here, I provides the sql server database scripts which can be very useful in many application. When we create registration form or user information form, there is one basic thing is user's location including his/her country, state and city. So we need to provide the list of world's (most of) all countries, states and cities to the user, so they can choose their location from the list.
So, here is the script for the SQL Server database in which there are three mapped tables CountryMaster, StateMaster and CityMaster. These tables are related to each other using Primary key and foreign key in the tables. So we can easily map the data whenever its required. You can manually insert data to these tables later, if any new country, state or city found in the world.
Following are the Database Diagram of these tables with their relationship.

So, here is the script for the SQL Server database in which there are three mapped tables CountryMaster, StateMaster and CityMaster. These tables are related to each other using Primary key and foreign key in the tables. So we can easily map the data whenever its required. You can manually insert data to these tables later, if any new country, state or city found in the world.
Following are the Database Diagram of these tables with their relationship.

Download the attached .rar file which contains the scripts for these tables and then execute them in your database.
Note: Please first execute the CountryData.sql file then StateData.sql file and at last CityData.sql file, because of relationship of tables to each other.


KAUSHALASH SRIVASTAVAPosted Aug 17, 2022, 1:31 AM EDT
I am facing problem in importing it . Can anybody help me
DivyaShree RPosted Oct 13, 2021, 3:16 AM EDT
Really appreciate the work. Thanks a lot.
Sagar MahajanPosted Jul 17, 2019, 9:06 PM EDT
How come u got 246 countries when google says there only 195 countries..
indresh kumarPosted Mar 16, 2019, 12:01 PM EDT
Good data for country
Ruchir GuptaPosted Jan 31, 2019, 10:10 PM EST
It has incorrect data as well as duplicate values in statemaster table
Ruchir GuptaPosted Jan 31, 2019, 9:03 PM EST
Has lots of duplicate keys
Atif AliPosted May 12, 2018, 7:01 PM EDT
Incorrect data , but nice idea , thanks for sharing
Nupoor PaneliyaPosted Oct 23, 2017, 9:10 AM EDT
Thanks for sharing this Jignesh! It really helped me.
Anonymous UserPosted Oct 7, 2017, 10:14 AM EDT
Thanks Man! Appreciate.
Sunil SinghPosted Sep 23, 2017, 10:10 PM EDT
Thank you very much Bro
sudha chimataPosted May 8, 2017, 5:36 AM EDT
Thanks, it helped me a lot
vidya shrungarePosted Apr 28, 2017, 10:27 PM EDT
Thanks for your contents it help me a lot.
Ashish SrivastavaPosted Apr 24, 2017, 12:18 AM EDT
Superb! Save googling ;)
Vaibhav DeshmukhPosted Nov 16, 2016, 12:19 AM EST
Thanks .... Almost what i need. Good job. Thanks again.
Ramesh BandiPosted Aug 2, 2016, 5:42 AM EDT
Thanks a lot man. Almost what i need. Good job. Thanks again.
Aravind ChembetiPosted Jul 12, 2016, 11:31 PM EDT
Saved lot of time collecting the data. Keep up the good job Jinesh.
Wajeed AliPosted May 23, 2016, 4:16 AM EDT
Thanks Jignesh found very usefull...keep it up.
leo leoPosted Apr 13, 2016, 1:44 AM EDT
Thank You its really helpfull : )
MdRameez MemonPosted Apr 6, 2016, 3:55 AM EDT
Thank You Very Much.