tags:

views:

44

answers:

1

Hello,

I am new to using the geography types in SQL Server 2008. I have a table in my database called "Location". "Location" has the following columns and types:

Location
--------
City nvarchar(256)
State nvarchar(256)
PostalCode nvarchar(25)
Latitude decimal(9, 6)
Longitude decimal(9, 6)

Each Location is related to a Store record in my database. I am trying to find the stores within a 10 mile radius or postal code or city/state that a user enters. To accomplish this, I know that I need to rely on geographies. At this time I have:

DECLARE @startingPoint geography;
SET @startingPoint=geography::STGeomFromText('POINT(-122.34900 47.65100)', 4326);

That gives me the starting point from a hard-coded textual value. However, I do not know how to convert a lat/long from my Location table into a geography instance.

How do I convert a lat/long in my database to a geography instance so I can continue to work on my query?

Thank you!

+2  A: 
select geography :: Point (Latitude,  Longtitude, 4326)
from Location.Location
geographika