Even though there are many ways of
working around the TEMDB and user database collation conflicts when using
#Temp_* tables. I ran into a situation where I couldn’t find a wayout. The
problem was with the SQL Spatial function STGeometryType.
Of what I realised, this function just
didn’t like the #Temp_* table collation even if the table was created with same
collation as the source table. I also couldn’t find a way of converting the
returned value to a simple text and neither was I able to explicitly convert it
to the required collation at the time of the equality operation.
The query that failed look like the following
SELECT *
FROM #Temp_tempt
WHERE Geometry_SPA.STIsValid()=1
AND Geometry_SPA.MakeValid().STGeometryType() IN ('LineString','MultiLineString')
AND Geometry_SPA.MakeValid().STLength()<0.1
FYI – The Geomerty columns don’t have
spatial collation
It appeared, when the geometry
verification function *.MakeValid().STGeometryType encountered the
collation problem but Geometry_SPA.MakeValid().STLength didn’t have such an
issue.
I overcome the issue by creating a
stage table in the same database to load the data which is a little too
primitive, but it works for now.
Comments
Post a Comment