SQL SERVER – World Shape files Download and Upload to Database – Spatial Database

During my recent, training I was asked by a student if I know a place where he can download spatial files for all the countries around the world, as well as if there is a way to upload shape files to a database. Here is a quick tutorial for it.

You can download the spatial file from here. If you cannot find the spatial file you are looking for, please leave a comment here, and I will send you the necessary details. Unzip the file to a folder and it will have the following content.

SQL SERVER - World Shape files Download and Upload to Database - Spatial Database spatial1

Then, download Shape2SQL tool from SharpGIS. This is one of the best tools available to convert shapefiles to SQL tables. Afterwards, run the .exe file.

When the file is run for the first time, it will ask for the database properties. Provide your database details.

SQL SERVER - World Shape files Download and Upload to Database - Spatial Database spatial2

Select the appropriate shape files and the tool will fill up the essential details automatically. If you do not want to create the index on the column, uncheck the box beside it. The screenshot below is simply explains the procedure. You also have to be careful regarding your data, whether that is GEOMETRY or GEOGRAPHY. In this example,  it is GEOMETRY data.

Click “Upload to Database”. It will show you the uploading process. Once the shape file is uploaded, close the application and open SQL Server Management Studio (SSMS).

SQL SERVER - World Shape files Download and Upload to Database - Spatial Database spatial3

SQL SERVER - World Shape files Download and Upload to Database - Spatial Database spatial4

Run the following code in SSMS Query Editor.

USE Spatial
GO
SELECT *
FROM dbo.world
GO

This will show the complete map of world after you click on Spatial Results in Spatial Tab.

SQL SERVER - World Shape files Download and Upload to Database - Spatial Database spatial5

SQL SERVER - World Shape files Download and Upload to Database - Spatial Database spatial6

In Spatial Results Set, the Zoom feature is available. From the Select label column, choose the country name in order to show the country name overlaying the country borders.

Let me know if this tutorial is helpful enough. I am planning to write a few more posts about this later.

Note: Please note that the images displayed here do not reflect the original political boundaries. These data are pretty old and can probably draw incorrect maps as well. I have personally spotted several parts of the map where some countries are located a little bit inaccurately.

DOWNLOAD SHAPE FILE

Reference : Pinal Dave (https://blog.sqlauthority.com)

Spatial Database, SQL Scripts, SQL Server, SQL Spatial, SQL Utility
Previous Post
SQL SERVER – Generate Report for Index Physical Statistics – SSMS
Next Post
SQLAuthority News – MS Access Database is the Way to Go – April 1st Humor

Related Posts

124 Comments. Leave new

  • Hi – The India shape file located under Asia is an older version (when UP, Bihar, and MP were not bifurcated). Is there an updated shape file for India (with state boundaries) that we can find somewhere? not have had much luck so far!

    thanks for your help!
    Manish

    Jan 11, 2011

    Reply
  • Please send spatial file

    Reply
  • how can we apply Data Mining concept on this Spatial Data

    Reply
  • hi….i have a question like if i want to map my sql table into map control can i map to direct to the the map control or what is the procedure do i need to follow….

    thanks in advance…

    Reply
  • hi,

    I have downloaded usstates shapefiles and shape2sql…but with shape2sql i am not able to see table in my database. If i am downloading world shape file that i can see that in my database but us state is not there…any reply on this will be appreciated

    Reply
  • Hi, great stuff you’ve put on here.

    How do I edit the text data (i.e. country code) in the shape file? For example, my country ISO code for the United Kingdom is GB, and in the shape file it’s UK. So all my UK data is not showing up on the map.

    Appreciate your help.

    Reply
  • Sir,
    I want to create shape file.i have idea about how to import data into sql server from shape file,but how to create shape file?please let me know?

    Thanks in advance..

    Reply
  • Heramb Sawant
    May 23, 2011 11:24 am

    Sir ,
    i m working on vehicle tracking project , i want to use aspmap tool for that i need .shp file of maps of india.
    i m not geting those map .also looking for examples to use .shp files as well as .tab files of maps.
    I m not getting .shp files for maps of india for various category.

    Reply
  • Thanks for the tutorial. It’s seems like the world.zip file is no longer availible. Can you please send

    Reply
  • Its just not listet on the page.
    Here you have the download-link:

    Reply
  • As Link Provided by you

    i try to find world map but i didn’t get one.can u help me.any i install that software which convert shape files to sql tables data.that isalso not working for me

    Reply
  • i think shale2sql has limitation. I tried to up load a large size file, but failed.

    Reply
  • grossi.giulia@gmail.com
    September 8, 2011 7:20 pm

    Hi Pinal, I use this program really often and it works fine, but I was wandering if it can also do a reverse swich from sql server to shp. Or do you kwon any program that can do this?

    Reply
  • Hello Pinal, I’m looking for the map of the whole world in the form of a shapefile, how can I get it? Alternatively, what procedure can I use to convert google earth maps into a shapefile?

    Reply
  • Hello Pinal i need shapefiles for whole over because i need to show Drill down SSRS report Containing google map, what procedure can I use to convert a shapefile into sql spatial data?

    Reply
  • Hello pinal, I need the shapefile of Saudia Arabia (KSA). It is urgent please.
    Thank you

    Reply
  • Hi Dev,

    Good morning.

    Can you please share the information of world.zip file.
    I would like to work with world.zip file to embed into map report in sql reports2008.

    I am eagrly looking for your reply.

    Thanks,
    kishore.
    [phone removed]

    Reply
  • Hi,
    I cannot find world.zip any where. Please advice.
    Thank

    Reply
  • Hi,
    I think I found the world map here (in the Global level, country boundaries).
    However, SSRS runs into error “The number of map point elements for map ‘Mapxxx’ exceeds the maximum limit for the map”. I even try it with 1 country and still have same error.
    Please help.
    Thank

    Reply
  • Hi,
    After I changed Map Resolution to 5 in Map Viewport Properties, the problem goes away. The map does not look nice like with the resolution is 0 but at least I can see the data which is really nice.
    Cheers
    PhuTri

    Reply

Leave a Reply