Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I am searching lattitude,longtude values in where condition i.e

Latitude LIKE '%'+@latitude+'%' and Longitude LIKE '%'+@Longitude+'%'
but lattitude,longtude datatypes is nvarchar so getting some problems in searching the data type is navrchar but I entered float values ....?
what is the alternate datatype instead of 'like'
Posted
Updated 18-Nov-13 4:57am
v2
Comments
Mike Meinz 18-Nov-13 9:43am    
There are several different formats used to specify latitude and longitude. If you are using Signed Degrees format (a signed numeric value), you can store in the database as a decimal number and compare it using >=, <- or = in a SQL Select statement Where clause. I wouldn't use the Like operator to compare latitude and longitude values.

See Latitude and longitude formats.

If you are using one of the Degrees-minutes-seconds formats to store latitude and longitude, the problem becomes a bit more difficult. Without knowing the format of you latitude and longitude values, it is difficult to provide help. I would urge you to use Signed Degrees format instead.
ZurdoDev 18-Nov-13 10:02am    
Why is it a problem? Perhaps show some sample data and explain why it's an issue.
RedDk 18-Nov-13 12:54pm    
I'll bet this question is about geospatial data types. In which case BOL(icrosoftm) is the place to gain insight.

1 solution

Get rid of the nonsense of storing numerical values formatted as characters! Use an appropriate numerical type (signed, with some decimal places).
Then your comparison could be e.g.
SQL
WHERE (Latitude BETWEEN 12 AND 13) AND (Longitude BETWEEN 78 AND 79)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900