Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
T-SQL创建函数和更新列_Sql_Sql Server_Tsql - Fatal编程技术网

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

我对整个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 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