June 7, 2016 at 10:34 am
For the site I want to use a google map which will plot all the available locations on the map. The issue is that this is not a new table, but rather an existing table I am modifying to add the latitude and longitude. This contains thousands of records and going through each record is going to be time consuming. I was wondering if there was a way to run a query to go through all the records and update lat/long, using the address fields?
June 7, 2016 at 11:42 am
pmb88 (6/7/2016)
For the site I want to use a google map which will plot all the available locations on the map. The issue is that this is not a new table, but rather an existing table I am modifying to add the latitude and longitude. This contains thousands of records and going through each record is going to be time consuming. I was wondering if there was a way to run a query to go through all the records and update lat/long?
Yes you would use an update statement for this. If you want help writing this update statement you need to provide some details. See the first link in my signature for best practices when posting questions.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 7, 2016 at 12:57 pm
Here is my table:
DECLARE @Locations table(
[LocID] [int] IDENTITY(1,1) NOT NULL,
[Location_Name] [varchar](64) NULL,
[Address] [varchar](60) NULL,
[City] [varchar](40) NULL,
[State] [char](2) NULL,
[Zip] [varchar](10) NULL
[Latitude] [decimal](9, 6) NULL,
[Longitude] [decimal](9, 6) NULL
)
How can I use the address fields with the record to retrieve the proper latitude and longitude and update those fields?
June 7, 2016 at 1:14 pm
pmb88 (6/7/2016)
Here is my table:
DECLARE @Locations table(
[LocID] [int] IDENTITY(1,1) NOT NULL,
[Location_Name] [varchar](64) NULL,
[Address] [varchar](60) NULL,
[City] [varchar](40) NULL,
[State] [char](2) NULL,
[Zip] [varchar](10) NULL
[Latitude] [decimal](9, 6) NULL,
[Longitude] [decimal](9, 6) NULL
)
How can I use the address fields with the record to retrieve the proper latitude and longitude and update those fields?
Do you need to determine the correct latitude and longitude values? If so then you need to call a webservice to get these values. There is no way to do this with just sql.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 7, 2016 at 1:25 pm
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply