0

HI When i am trying to insert a record in one of the tables in my db using the following query its not working

insert into T_HTK_ZONES(ZONE_NAME,ZONE_GEOLOCATION) 
    values('TMH',GEOGRAPHY::STGeomFromText('POLYGON((86.17768049240112 22.799901048907312, 86.17795944213867 22.802432999994917, 86.18175745010376 22.802531903379716, 86.18210077285767 22.799584551714144, 86.17946147918701 22.79849658700764, 86.17768049240112 22.799901048907312))', 4326))

This is not working

but this is working

insert into T_HTK_ZONES(ZONE_NAME,ZONE_GEOLOCATION)    
    values('TMH',GEOGRAPHY::STGeomFromText('POLYGON((-122.358 47.653 , -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326))

Here is the error.

A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": System.ArgumentException: 24200: The specified input does not represent a valid geography instance. System.ArgumentException: at Microsoft.SqlServer.Types.SqlGeography.ConstructGeographyFro‌​mUserInput(GeoData g, Int32 srid) at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(Ope‌​nGisType type, SqlChars taggedText, Int32 srid) at Microsoft.SqlServer.Types.SqlGeography.STGeomFromText(SqlCha‌​rs geometryTaggedText, Int32 srid)

Can anyone pls explain

SS_DBA
  • 2,403
  • 1
  • 11
  • 15
  • Are you getting an error trying to insert these values? – SS_DBA Jan 04 '17 at 14:03
  • Yes for first query I am getting error second query is working fine i want to know why first is not working – user3101883 Jan 04 '17 at 14:04
  • Can you post the error? – SS_DBA Jan 04 '17 at 14:04
  • A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": System.ArgumentException: 24200: The specified input does not represent a valid geography instance. System.ArgumentException: at Microsoft.SqlServer.Types.SqlGeography.ConstructGeographyFromUserInput(GeoData g, Int32 srid) at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid) at Microsoft.SqlServer.Types.SqlGeography.STGeomFromText(SqlChars geometryTaggedText, Int32 srid) – user3101883 Jan 10 '17 at 12:06
  • What is the datatype of `ZONE_GEOLOCATION`? I did a query with your values into a variable of `georgaphy` and it worked fine in Query Analyzer. – SS_DBA Jan 10 '17 at 12:58
  • It's of system.geography type – user3101883 Jan 10 '17 at 12:59
  • Have you tried that insert statement in SSMS? – SS_DBA Jan 10 '17 at 13:00
  • I tried inserting it in sql server using query function availaible in visual studio not tried with SSMS – user3101883 Jan 10 '17 at 13:02
  • See if this helps. http://stackoverflow.com/questions/8271349/the-specified-input-does-not-represent-a-valid-geography-instance-exception-wh – SS_DBA Jan 10 '17 at 13:17
  • 1
    That works Reversing the order of points works Thanks a lot for the help – user3101883 Jan 17 '17 at 06:13

0 Answers0