1

I am new to the whole SQL Server / T-SQL area but I am basically trying to update a row in my database with a particular function and can't seem to find out how to do it.

First there are 2 columns latitude which has a value and TenLatMin which is null what I first do is check for all the null values

Select * 
from zipcodes 
where TenLatMin is null

DECLARE @LATMIN FLOAT
DECLARE @convert FLOAT

SET @convert= .14493
// I would like to get the latitudes from the Select and plug it there
SET @LATMIN= round(latitude - @convert,8)
// Then do the calculation and update the field
update zipcodes 
set TenLatMin =

The select works because I get a list of all the Null values now what I want to do is get the latitude of each row that has a Null value and use that inside the small @LATMIN calculation so that then I can set TenLatMin to that value..

Any suggestions would be great and as I said before each row already has a latitude value .

1 Answer 1

3

You can update all the records with missing TenLatMin is a single statement.

declare @convert float
set @convert = .14493

update zipcodes
set TenLatMin = ROUND(latitude - @convert, 8)
where TenLatMin is null
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.