2017-04-22 58 views
0

我从气象站的测量数据更新在SQL Server中一个表的列,与站名(希伯来文):从另一个

enter image description here

我也创建了这些气象站的表它们的纬度和经度:

enter image description here

我已经写了应该从第二纬度/多头更新第一表的查询,但它不工作:

update t1 
set t1.MeasurementLat = t2.Latitude, 
    t1.MeasurementLong = t2.Longitude 
from [dbo].[Measurements] as t1 
inner join [dbo].[StationCoords] as t2 on t1.StationName like t2.Station 

我认为这是与站名正在读取的方式,也许是与编码的问题,因为这个查询就会回一个空的结果,太:

SELECT TOP (5) * 
FROM [dbo].[Measurements] 
WHERE [StationName] = 'אריאל מכללה'; 

任何想法?

+0

尝试使用'='而不是'like'。和你的例子名称是不一样的。 –

回答

1

您的示例名称不一样。也许这将工作:

update m 
    set MeasurementLat = sc.Latitude, 
     MeasurementLong = sc.Longitude 
    from dbo.[Measurements] m join 
     dbo.[StationCoords] sc 
     on m.StationName like sc.Station + '%'; 
+0

哪个示例名称不一样? –

+0

它可行,但我不确定我做错了什么,你能解释一下吗? –

+1

@BorisK。 。 。 “Station”和“Station Name”不一样。 ''LIKE'没有通配符,很像'='。 –