Search code examples
sql-serversql-server-2008-r2spatialsqlgeometry

Insert geometry values in SQL Server 2008 R2


I want to insert GEOMETRY values into a table. For which I have a table with three columns as shown below:

Table: geo

create table geo
(
p1 float,
p2 float,
Paths GEOMETRY
);

Input values: I have following values

p1 = 22.9901232886963
p2 = 87.5953903123242

My bad try:

INSERT INTO geo(Paths)
VALUES (geometry::STGeomFromText('POLYGON (22.9901232886963,87.5953903123242)', 4326));

Solution

  • Your WKT is malformed. This works for me:

    declare @g geometry = geometry::STGeomFromText(
        'POINT (22.9901232886963 87.5953903123242)'
        , 4326);
    
    select @g
    

    Note too that it's a point and not a polygon.