Free cookie consent management tool by TermsFeed Policy Generator
  • SQL Server Video
  •    11 page views
  •   823 video views
  • 2024, November 17, Sunday

#017 How to Insert Geopoint in SQL Server

Apresentamos nesse vídeo como armazenar pontos geográficos com a inteligência geo espacial do banco de dados SQL Server.

We'll get to know the techniques:

1. Create Table with Geographic Column (GEOGRAPHY):

  • To create a table with a geographic column, you can use the GEOGRAPHY data type in SQL Server.

    CREATE TABLE Locations (
      ID INT PRIMARY KEY,
      Name: NVARCHAR(50),
      GEOGRAPHY coordinates
    );
    

2. Insert Record in Table Containing Geographic Point, Latitude, and Longitude (POINT):

  • Insert records into the table with geographic information, using the POINT data type to represent points.

    INSERT INTO Locations (ID, Name, Coordinates)
    VALUES (
      1,
      'Local1',
      GEOGRAPHY::Point(40.7128, -74.0060, 4326) -- Latitude, Longitude, SRID
    );
    

3. View map by using SQL Server Management Studio (SSMS):

  • Use the graphical functionality of SQL Server Management Studio to visualize the map.

    SELECT ID, Name, Coordinates.ToString() AS Coordinates
    FROM Locations;
    
  • Run the query, and then click the query result in the Coordinates column in SSMS. It will open a window that will display the point on the map.

Running these examples assumes that you are already using a version of SQL Server that supports geographic data (such as SQL Server 2008 and later versions) and that SSMS is also configured to work with geographic data. Be sure to replace the latitude and longitude values with the actual values you want to enter.

This content contains
  • Content Video
  • Language Portuguese
  • Duration 5m 44s
  • Subtitles Não

  • Reading time 0 min 58 seg

avatar
Fabio Santos

Data Scientist and Consultant for Digital and Analytics Solutions


  • Share

Youtube Channel

@fabioms

Subscribe now