T-SQL创建函数和更新列
我对整个SQL Server/T-SQL领域都是新手,但我基本上是在尝试使用特定函数更新数据库中的一行,似乎不知道如何进行更新 首先有两列T-SQL创建函数和更新列,sql,sql-server,tsql,Sql,Sql Server,Tsql,我对整个SQL Server/T-SQL领域都是新手,但我基本上是在尝试使用特定函数更新数据库中的一行,似乎不知道如何进行更新 首先有两列latitude有一个值,而TenLatMin为空,我首先要做的是检查所有的空值 Select * from zipcodes where TenLatMin is null DECLARE @LATMIN FLOAT DECLARE @convert FLOAT SET @convert= .14493 // I would like to get
latitude
有一个值,而TenLatMin
为空,我首先要做的是检查所有的空值
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 =
select
之所以有效,是因为我现在得到了所有空值的列表,我想做的是得到每一行的latitude
,它有一个空值,并在小的@LATMIN
计算中使用,这样我就可以将TenLatMin
设置为该值
任何建议都很好,正如我前面所说的,每一行都有一个纬度值。您可以使用缺少的TenLatMin语句更新所有记录
declare @convert float
set @convert = .14493
update zipcodes
set TenLatMin = ROUND(latitude - @convert, 8)
where TenLatMin is null