Insert geometry values in SQL Server 2008 R2

MAK picture MAK · Dec 24, 2014 · Viewed 7k times · Source

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));

Answer

Ben Thul picture Ben Thul · Dec 24, 2014

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.