【发布时间】:2016-11-18 13:59:09
【问题描述】:
对于每个名字和姓氏,我只想将它们合并并更新到同一个“名称”表中的全名列中。
这应该发生在表中的每一行。这些列是 Id、FirstName、LastName 和 FullName。
任何帮助将不胜感激
update Names n
set n.FullName = (
select CONCAT(FirstName,' ',LastName)
from Names a
where n.Id = a.Id
)
where n.FullName is null
and n.FirstName is not null and n.LastName is not null
【问题讨论】:
-
您可以使用 Select 中的更新,如下所述:stackoverflow.com/questions/2334712/…
标签: sql-server tsql