I have a table with a geography column that stores the location of a property.
I have a procedure something like this -
PROCEDURE dbo.spt_sold_property_search
(
@latitude_min Decimal(9,6),
@latitude_max Decimal(9,6),
@longitude_max Decimal(9,6),
@longitude_min Decimal(9,6)
)
AS BEGIN
SET NOCOUNT ON
SELECT * FROM [dbo].[sold_property] AS p WITH(NOLOCK)
WHERE p.location ***is in the lat/long min max bounds***
END
What would I need in the where clause to check if the geography point is in the bounds of the Lat/Long min max? It is an large dataset so performance is a critical.
Should I be creating a Geography SQL type in code from the bounds and pass that into the proc as a procedure?
I was also considering creating 2 calculated int columns (lat/long) which would be created on insert, and then simple < > as I heard that is faster than Geography queries.