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

  • hello sir
    frm where i download dis shape 2 sql tool n is it free n is it compatible with sql server 2005

    Reply
  • Hi I need a world shape file which is not available at the site which you have cited. Can you please share that here?

    Reply
  • Hi Sir,

    How can we create shape file from SQL Database?

    Reply
  • Hello Can you please send me shape files for world map?
    Thanks

    Reply
  • i look for maps from iran.
    i cant find any maps heir
    do you have any idea
    thanks

    Reply
  • i m getting problem in downloading shape 2 sql tool ….plz help me in that

    Reply
  • please send me shape files as soon as possible

    Reply
  • Dears,
    I can’t find the spatial file of Saudi Arabia. would you send it to me please?

    Reply
  • i am looking for maps from iran.
    would you send it to me
    thanks

    Reply
  • Pradeep Kumar Nadella
    January 9, 2012 7:42 pm

    Hi Pinal,

    I am unable to find World.Zip Spatial file in VDS Techologies, Please send me Required Links ..

    Reply
  • Pradeep Kumar Nadella
    January 9, 2012 7:44 pm

    Hi Pinal,

    I am unable to find World.Zip Spatial file in VDS Technologies,Please send me the Required Links

    Reply
  • when i execute this query
    USE Spatial
    GO
    SELECT *
    FROM dbo.world
    GO
    it is taking long time in debugging…..and debugging.
    its neither gave error nor any other msg….
    only time increases.what to do?

    Reply
  • HI Pinal,

    Please help me world.shp file as I’m not able to locate it.

    Reply
  • I have Followed the steps, I downloaded the US Zip file, and shape2sql, but when I run I am getting a SQL connection error for some reason. I’ve done the normal degugging (remote access, permissions, Windows authentication vs user) but I can not seem to figure out what the problem is. My goal is to build a table of zip codes with Lat / Long, as I only have address data and what to chart on a map using RSS 3.0.
    Thanks,

    Jeremy

    Reply
  • Hi, Pinal:
    Fantanstic! But I was unable to find world map (only Administrative, Coastline and son on). Can you help?

    Many thanks,
    Steven

    Reply
  • hi..nice work here…can i obtain Nigeria’s shapefiles here?

    Reply
  • Hi Pinal, thanks for the great article. I downloaded the US states map, and see the progress bar upload. But no tables under the Database. Any help is appreciated.

    Reply
  • Is there any artcle available for creating our own custom shape file for similar use ?

    Reply
  • ganesh yadav
    June 9, 2012 1:33 pm

    I tried to upload sh file but it not do anything so plz instruct how it will upload in DB.

    Reply
  • WILL YOU PROVIDE ME THE ASIA.SHP FILE

    Reply

Leave a Reply