Category Archives: SQL Server

Geocoding in SQL Server with the Bing Maps Locations API

Almost every SQL Server database contains “spatial” data. That information might not use the dedicated geography or geometry spatial datatypes but, more likely, could be a table of customer addresses, the name of a city of region for which a … Continue reading

Posted in Bing Maps, SQL Server | Tagged , , | 30 Comments

Gridding Geometries (or, “Creating patchwork animals in SQL Server”)

This is one of those things that I can’t imagine anybody would ever really want to do but, seeing as I haven’t posted anything for a while, I thought I’d write about it just in case it’s of use to … Continue reading

Posted in Spatial, SQL Server | Tagged , , | 3 Comments

“Point-of-Maximal Distance” queries (AKA Variations on a Theme of Nearest-Neighbours)

Nearest neighbour queries (or, for my international readers, nearest-neighbor queries), are a pretty common query pattern used in location-based applications and spatial analysis:- given a set of known locations of restaurants, customers, stations etc.,  “What/where is the nearest X to … Continue reading

Posted in Spatial, SQL Server | Tagged , , , | 2 Comments

SQL Server 2012 – What’s New for Spatial?

So Microsoft launched SQL Server 2012 today, and you can download the SQL 2012 Express edition right now from http://www.microsoft.com/sqlserver/en/us/get-sql-server/try-it.aspx No doubt there will be lots of people writing blog articles about the various new features – AlwaysOn, Column Store … Continue reading

Posted in Spatial, SQL Server | Tagged , , , , | 7 Comments

Drawing Fractals with SQL Server Spatial

I can’t think of any practical purpose for this code, but here’s a recursive SQLCLR procedure to draw a Sierpinski triangle fractal (or, at least, an approximation of one to a given level of detail) in SQL Server just because … Continue reading

Posted in Spatial, SQL Server | Tagged , , , , , | 1 Comment

Cleaning up artefacts created by Reduce()

The Reduce() method simplifies geography or geometry instances by removing vertices. Depending on the situation, this can sometimes cause a Polygon instance to collapse in on itself, degenerating into a LineString, or even a single Point. For example, in the … Continue reading

Posted in Spatial, SQL Server | Tagged , | 1 Comment

Updating a SQL Server Table with Nearest Neighbours (Optimised for SQL Server 2012 / SQL Azure)

So I’ve been trying to think of some examples that make use of the Garmin POI data from my last post. Seeing as POI data naturally lends itself to nearest-neighbour queries, I thought I’d write a little about those. The … Continue reading

Posted in Spatial, SQL Server | Tagged , , , | 4 Comments