I am trying to create a polygon in a geography datatype in SQL Azure but It keep getting me an error that the specified input doesn't represent a valid geography instance ALTHOUGH when I change the datatype from geograhy to geometry it works fine.
I have tried out this
declare @g geography;
set @g = geography::STGeomFromText('POLYGON((31.02350 30.02944, 31.02350 30.02944, 31.00857 30.04697, 31.00857 30.04697, 30.99415 30.06346, 30.99415 30.06346, 30.97424 30.08708, 30.97424 30.08708, 30.96874 30.08768, 30.96874 30.08768, 30.95947 30.08322, 30.95947 30.08322, 30.94660 30.07475, 30.94660 30.07475, 30.94282 30.07193, 30.94282 30.07193, 30.93441 30.07267, 30.93441 30.07267, 30.93338 30.06599, 30.93338 30.06599, 30.94557 30.05143, 30.94557 30.05143, 30.95140 30.04489, 30.95140 30.04489, 30.92651 30.02990, 30.92651 30.02990, 30.89802 30.01147, 30.89802 30.01147, 30.86746 29.99006, 30.86746 29.99006, 30.83794 29.97222, 30.83794 29.97222, 30.81665 29.95675, 30.81665 29.95675, 30.87158 29.88325, 30.87158 29.88325, 31.02350 30.02944, 31.02350 30.02944, 31.00857 30.04697, 31.00857 30.04697, 30.99415 30.06346, 30.99415 30.06346, 30.97424 30.08708, 30.97424 30.08708, 30.96874 30.08768, 30.96874 30.08768, 30.95947 30.08322, 30.95947 30.08322, 30.94660 30.07475, 30.94660 30.07475, 30.94282 30.07193, 30.94282 30.07193, 30.93441 30.07267, 30.93441 30.07267, 30.93338 30.06599, 30.93338 30.06599, 30.94557 30.05143, 30.94557 30.05143, 30.95140 30.04489, 30.95140 30.04489, 30.92651 30.02990, 30.92651 30.02990, 30.89802 30.01147, 30.89802 30.01147, 30.86746 29.99006, 30.86746 29.99006, 30.83794 29.97222, 30.83794 29.97222, 30.81665 29.95675, 30.81665 29.95675, 30.87158 29.88325, 30.87158 29.88325, 30.92651 29.89962, 30.92651 29.89962, 30.96737 29.89129, 30.96737 29.89129, 31.06419 29.85914, 31.06419 29.85914, 31.08410 29.89664, 31.08410 29.89664, 31.09612 29.92700, 31.09612 29.92700, 31.09921 29.94693, 31.09921 29.94693, 31.04908 30.00017, 31.04908 30.00017,31.02350 30.02944))',4326);
SELECT @g
and this
declare @g geography;
set @g = geography::STPolyFromText('POLYGON((31.02350 30.02944, 31.02350 30.02944, 31.00857 30.04697, 31.00857 30.04697, 30.99415 30.06346, 30.99415 30.06346, 30.97424 30.08708, 30.97424 30.08708, 30.96874 30.08768, 30.96874 30.08768, 30.95947 30.08322, 30.95947 30.08322, 30.94660 30.07475, 30.94660 30.07475, 30.94282 30.07193, 30.94282 30.07193, 30.93441 30.07267, 30.93441 30.07267, 30.93338 30.06599, 30.93338 30.06599, 30.94557 30.05143, 30.94557 30.05143, 30.95140 30.04489, 30.95140 30.04489, 30.92651 30.02990, 30.92651 30.02990, 30.89802 30.01147, 30.89802 30.01147, 30.86746 29.99006, 30.86746 29.99006, 30.83794 29.97222, 30.83794 29.97222, 30.81665 29.95675, 30.81665 29.95675, 30.87158 29.88325, 30.87158 29.88325, 31.02350 30.02944, 31.02350 30.02944, 31.00857 30.04697, 31.00857 30.04697, 30.99415 30.06346, 30.99415 30.06346, 30.97424 30.08708, 30.97424 30.08708, 30.96874 30.08768, 30.96874 30.08768, 30.95947 30.08322, 30.95947 30.08322, 30.94660 30.07475, 30.94660 30.07475, 30.94282 30.07193, 30.94282 30.07193, 30.93441 30.07267, 30.93441 30.07267, 30.93338 30.06599, 30.93338 30.06599, 30.94557 30.05143, 30.94557 30.05143, 30.95140 30.04489, 30.95140 30.04489, 30.92651 30.02990, 30.92651 30.02990, 30.89802 30.01147, 30.89802 30.01147, 30.86746 29.99006, 30.86746 29.99006, 30.83794 29.97222, 30.83794 29.97222, 30.81665 29.95675, 30.81665 29.95675, 30.87158 29.88325, 30.87158 29.88325, 30.92651 29.89962, 30.92651 29.89962, 30.96737 29.89129, 30.96737 29.89129, 31.06419 29.85914, 31.06419 29.85914, 31.08410 29.89664, 31.08410 29.89664, 31.09612 29.92700, 31.09612 29.92700, 31.09921 29.94693, 31.09921 29.94693, 31.04908 30.00017, 31.04908 30.00017,31.02350 30.02944))',4326);
SELECT @g
but both returned the same error although this works fine
declare @g geometry;
set @g = geometry::STPolyFromText('POLYGON((31.02350 30.02944, 31.02350 30.02944, 31.00857 30.04697, 31.00857 30.04697, 30.99415 30.06346, 30.99415 30.06346, 30.97424 30.08708, 30.97424 30.08708, 30.96874 30.08768, 30.96874 30.08768, 30.95947 30.08322, 30.95947 30.08322, 30.94660 30.07475, 30.94660 30.07475, 30.94282 30.07193, 30.94282 30.07193, 30.93441 30.07267, 30.93441 30.07267, 30.93338 30.06599, 30.93338 30.06599, 30.94557 30.05143, 30.94557 30.05143, 30.95140 30.04489, 30.95140 30.04489, 30.92651 30.02990, 30.92651 30.02990, 30.89802 30.01147, 30.89802 30.01147, 30.86746 29.99006, 30.86746 29.99006, 30.83794 29.97222, 30.83794 29.97222, 30.81665 29.95675, 30.81665 29.95675, 30.87158 29.88325, 30.87158 29.88325, 31.02350 30.02944, 31.02350 30.02944, 31.00857 30.04697, 31.00857 30.04697, 30.99415 30.06346, 30.99415 30.06346, 30.97424 30.08708, 30.97424 30.08708, 30.96874 30.08768, 30.96874 30.08768, 30.95947 30.08322, 30.95947 30.08322, 30.94660 30.07475, 30.94660 30.07475, 30.94282 30.07193, 30.94282 30.07193, 30.93441 30.07267, 30.93441 30.07267, 30.93338 30.06599, 30.93338 30.06599, 30.94557 30.05143, 30.94557 30.05143, 30.95140 30.04489, 30.95140 30.04489, 30.92651 30.02990, 30.92651 30.02990, 30.89802 30.01147, 30.89802 30.01147, 30.86746 29.99006, 30.86746 29.99006, 30.83794 29.97222, 30.83794 29.97222, 30.81665 29.95675, 30.81665 29.95675, 30.87158 29.88325, 30.87158 29.88325, 30.92651 29.89962, 30.92651 29.89962, 30.96737 29.89129, 30.96737 29.89129, 31.06419 29.85914, 31.06419 29.85914, 31.08410 29.89664, 31.08410 29.89664, 31.09612 29.92700, 31.09612 29.92700, 31.09921 29.94693, 31.09921 29.94693, 31.04908 30.00017, 31.04908 30.00017,31.02350 30.02944))',4326);
SELECT @g
Your coordinates list are no well formed and causes error in SQLAzure parser
Please fix your coordinates and it will work with you using
geography::STPolyFromText