I have an sql statement that is not compatible with the Sql Geometry
type so i am trying to revamp it to make it work.
The basic gist of it is something like this:
Select distinct A,B,C,D,SHAPE FROM TABLE1 UNION SELECT A,B,C,D,SHAPE FROM TABLE2
So the results of a complex distinct statement on two different (but similar) tables is unioned.
The problem is that the SQL Geometry
type (the SHAPE field) cannot be included in a distinct statement because it is not a comparable type.
I'm okay with removing the SHAPE
field from both of the subqueries that take part in the union. But i want to get it back after those subqueries are parsed.
I can get the SHAPE
field if i know the value of column A.
So my question is: how can i remove a field from the distinct statements in the two subqueries but then get that field back (along with the rest of the fields) in the result set by joining it in on another column (A)?
You can cast to VARBINARY(MAX), and then cast back.
Will this work?