Upgrading SQL’08 to SQL’12 for better Geography support

Users of SQL Server 2008′s native Geography type were a little disappointed when try tried to use geometries such as this one… MULTIPOINT (55 55, -55 55, -55 -55).  SQL Server 2008 responds with the error:

A .NET Framework error occurred during execution of user-defined routine or aggregate “geography”: 

Microsoft.SqlServer.Types.GLArgumentException: 24205: The specified input does not represent a valid geography instance because it exceeds a single hemisphere. Each geography instance must fit inside a single hemisphere. A common reason for this error is that a polygon has the wrong ring orientation. To create a larger than hemisphere geography instance, upgrade the version of SQL Server and change the database compatibility level to at least 110.

If those directions are cryptic, the solution is pretty easy.  

First, back up all your databases, in case something goes wrong.  Second, upgrade your SQL 2008 instance to SQL 2012 (you may have to update your service packs on 2008 first).  Finally, for each database, go into SQL Server Management Studio, and right-click your database to get its properties.  Under Options, change the Compatilibity level to “SQL Server 2012″.

Image

That should be enough to fix these Geography errors.  You can test your success with a simple query such as SELECT geography::STGeomFromText(‘MULTIPOINT (55 55, -55 55, -55 -55)’, 4326)

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s