Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
During the purposeful misuse of a geography data type:

DECLARE @gxxx geography;
SET @gxxx = geometry::STGeomFromText('POLYGON((-118.934303 40.883523, -72.279144 42.769298, -73.991066 40.739213, -105.828393 28.568069, -118.934303 40.883523))',0);
SELECT @gxxx.STArea();

I get this error:

"Msg 206, Level 16, State 2, Line 2
Operand type clash: sys.geography is incompatible with sys.geometry"

So I was wondering, even looked up the object in help:

SELECT * FROM sys.geometry

Or:

SELECT * FROM sys.geography

Should return something, no?

There's no such thing as sys.geography or sys.geometry ... so how is this an error message?

(Yes, I CAN see that my T-SQL disdirection is evil .. hence the title content)
Posted
Updated 24-Oct-12 8:55am
v2

1 solution

Unless you have created the table sys.geometry and sys.geography you would simply get an "Invalid object name 'sys.geometry' which is entirely valid as the tables don't exist.

geometry and geography are System Data Types so they can't be interchanged with each other so of course you'll get the Operand type clash error.

Either I'm missing something in your question, or everything is as it should be.
 
Share this answer
 
Comments
RedDk 24-Oct-12 14:51pm    
Ok,

I saw that there's no object. And that invalidates any time factor during my query because there's nothing to point my question at.

But using reverse logic then, doesn't "sys." get prefixed to EVERY variable I use in a DECLARE statement?

Really, there's nothing to be missed. My original error geography/geometry swap cancels any rational question about the returns from the interface at rt but it's that old %-substitution that's tiggering my curiosity about how the error is generated.
fjdiewornncalwe 24-Oct-12 14:54pm    
The system is trying to auto cast your geometry type to a geography type, so the = operand is the action where the error occurs, so operand type clash is what you get.
RedDk 24-Oct-12 15:01pm    
Got it,

Incidently, after adding the "close" coordinates for proper "geography", and correcting the clash by making everything geopgraphy:

DECLARE @gxxx geography;

SET @gxxx = geography::STGeomFromText('POLYGON((-118.934303 40.883523, -72.279144 42.769298, -73.991066 40.739213, -105.828393 28.568069, -118.934303 40.883523))',4326);

SELECT @gxxx.STArea();

I get another error ... Msg 6522 ... (sp) " ... The specified input does not represent valid geography because it exceeds a single hemisphere" ...

Too much information?The next peice of the message goes:

" A common reason for this error is that a polygon has the wrong ring orientation."

On to more investigation ...Thanks Marcus!

[EDIT]


For completeness' sake, some good form and something that looks like a plausible answer:


DECLARE @gxxx geometry;

SET @gxxx = geometry::STGeomFromText('POLYGON((337031.58 4527628.01, 722607.00 4738786.85, 585187.12 4510297.40, 418979.91 3160412.97, 337031.58 4527628.01))',0);

SELECT @gxxx.STArea();

Query answer:198472128803.033

Cool ...

[END EDIT]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900