Working with maps and database, SQL Server 2008 may help you with this new data type: geography .
This datatype takes part in spatial data features introduces in SQL Server 2008.
When you want to select location, in 50KM from xyz (a place well known), the simplest question is: is distance from center less than 50 km ?
Here is a very simple example about it
DECLARE @area geography;
SET @area = geography::STGeomFromText('POINT(' +
CAST(@LatitudeArea as nvarchar(50)) + ' ' +
CAST(@LongitudeArea as nvarchar(50)) + ')', 4326) ;
DECLARE @distance int;
SELECT @distance =
(geography::STGeomFromText('POINT(' +
CAST(@LatitudePoint as nvarchar(50)) + ' ' +
CAST(@LongitudePoint as nvarchar(50)) +')', 4326)).STDistance(@area);
IF (@distance < @RadiusArea *1000)
RETURN 1
RETURN 0
Technorati Tags: SQL Server 2008, Spatial Data, Bing Maps.
Tags: SQLServer