Amid Gol
Amid Gol

Reputation: 325

polygon does'nt work when using my database but works fine with master in sql server geography

STPolyFromText function works fine with both clock-wise and anti-clock-wise order of points when using master, but not working in anti-clock-wise mode when i use myDB. Here is my code:

use MyDB
go

DECLARE @polygon    geography    

DECLARE @clock_wise nvarchar(500)='POLYGON((35.2515 46.9657,35.2874 46.9784,35.3162 46.9466,35.3431 46.9817,35.3506 47.0122,35.3166 47.0324,35.3367 47.0541,35.3256 47.0768,35.3004 47.0673,35.2969 47.0479,35.2747 47.0527,35.2516 47.0521,35.2506 47.0146,35.2515 46.9657))'
DECLARE @anti_clock_wise nvarchar(500)='POLYGON((35.708 51.7622,35.6211 51.1277,35.4761 51.3704,35.7952 51.2544,35.5078 51.4838,35.5559 51.6161,35.7448 51.4571,35.8509 51.6945,35.8362 51.3961,35.708 51.7622))'

SET @polygon = geography::STPolyFromText(@anti_clock_wise,4326)   
select @polygon

Upvotes: 2

Views: 185

Answers (1)

Hamed Heidari
Hamed Heidari

Reputation: 26

Change your compatibility mode from SQL Server 2008 (100) to SQL Server 2012 (110).

Upvotes: 1

Related Questions