Quick notes about SQL Server 2008's new location data types

Posted: (EET/GMT+2)

 

I today had a change to play around just a little bit with SQL Server 2008, and of course I wanted to test the new geography related data types. To do so, I created a simple table like this:

CREATE TABLE [dbo].[Customers](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](50) NOT NULL,
    [Phone] [nvarchar](50) NULL,
    [Location] [geography] NULL
)

This is how it looks like in the SQL Server Management Studio:

Note that if you want to use this data type from your C# applications, you need to make sure you add a reference to the assembly Microsoft.SqlServer.Types. Otherwise, you cannot access the field in your SQL queries with for example the SqlCommand or SqlDataReader classes.