So, I have 3 columns: building_name, latitude, longitude.
Some of the lats and longs haven't been filled in, however they have in other records. This means I can extract the latitude and longitude on other records matching the building name.
I need to do the following:
What's the best way to go about this?
Try this query. Because I didn't have a sample table, I couldn't test
WITH CTE1 AS
(SELECT building_name, latitude, longitude FROM TBL WHERE ISNULL(building_name ,'') <> '' AND ISNULL(latitude ,'') <> '' AND ISNULL(longitude ,'') <> '') ,
CTE2 AS
(SELECT building_name, latitude, longitude FROM TBL WHERE ISNULL(building_name ,'') <> '' AND ISNULL(latitude ,'') = '' AND ISNULL(longitude ,'') = '')
UPDATE CTE2 SET latitude = CTE1.latitude , longitude = CTE1.longitude FROM CTE2 INNER JOIN CTE1 ON CTE2.building_name = CTE1.building_name