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)

, , , ,
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

121 Comments. Leave new

  • Are there any particular settings/configuration for SQL Server 2008 express to be able to import shape file? I have downloaded Shape2Sql.exe , opened one of the shape file, clicked on Upload to databse and nothing is happening or Cancel shows up and then “Upload to databse” shows up again.Am I missing something?

    Reply
  • Hi,

    I am unable to get the shape files from the above given site. I need shape files for Asian countries like India,China,Malaysia,Singapore and for Europe I need it for UK, Germany and France. I appreciate if you can share those shape files with me thru my email:nikkijyos@yahoo.com.

    Regards,
    Nirmal

    Reply
  • Hi Pinal,
    I want to know the location name based on longitude and latitude. How can we get using spatial database. Is there any option available.

    Reply
  • please send me files of india and its states.. i want all files which u mentioned above

    Reply
  • Lazarescu Florin
    October 15, 2013 1:24 pm

    Hi. I need the 3 world items that you put in the photo. Please reply me and help. I accesed the link and i don’t works. Regards, Florin.

    Reply
  • Hi Pinal, Urgently I need India state and district wise geom data.. Can you please tell where i need to download..? and i download SqlspatialTool but it’s show badimagefileformat error while loading the .shp file.. Thanks in Advance

    Reply
  • I am not able to download the worldmap shapefile data ..can u plz send me

    Reply
  • Hi Pinal,please help me to download the .shp file for the world .I am not able to download the .shp file by provided link.

    Reply
  • Hi am looking for indian state level shape file please give me the link or send me the …zip..urgently needed….

    Reply
  • HI ,
    I need Europe Shape file, can any one give me exact link where to download it
    its some what urgent

    Thanks in ADvance..Sri

    Reply
  • Hi Pinal,

    I have used the world map from geocommons.com site in my SSRS reports. In the BIDS preview, I can see the map rendered. I deployed and there is no error. But when I browse the file from report manager, i just see a blank screen. Map is not rendered. Any clues?

    Anyone has encountered this kind of issue?

    Thanks and Best regards,
    Ganesh

    Reply
  • Thanks Friend I learn something new today

    Reply
  • Pinal, can’t find the shape2sql.exe file – links at the top no longer seem to work – almost looks like could be link to virus site as it gives compilation error in IE. Could you verify and correct the link?

    Reply
  • HI pinal I am not able to download spatial data. can you please send.

    Reply
  • Hi sir,

    I’m Aravind from chennai. so many time your blogs is useful for me. Now I’m struck in spatial database. I’m not able to download spatial database. Can u send the zip file for me.
    [email removed]
    Thanks in Advance

    Reply
  • I am not able to download the worldmap data..can u plz send me

    Reply
  • Hi All, Please try again, I have fixed the link to download spatial file. Thank you!

    Reply
  • the link wont show the file to download..not is it automatically downloading anything

    Reply
  • Hi Pinal,
    I did follow your steps but I get below error:

    Could not isert row#1:
    Name: Guatemala
    Capital: Guatemala

    System.DllNotFoundException: Unable to load DLL ‘SqlServerSpatial.dll’…

    Reply
  • Hi Is there a world map with the states defined as well as countries?

    Reply

Leave a Reply

Menu