SELECT rollID
FROM [dbo].[dbo_Roll] a
INNER JOIN [evt_Building Permits] b
ON LEFT(a.rollnumber, LEN(a.rollnumber)-4) = b.rollnumber COLLATE DATABASE_DEFAULT
我想将结果更新到此表[evt_Building Permits].roll_id = [dbo].[dbo_Roll].rollID
?
我怎样才能达到这个目标?
答案 0 :(得分:1)
试试这个
UPDATE b
SET b.roll_id = a.rollID
FROM
[dbo].[dbo_Roll] a
INNER JOIN
[evt_Building Permits] b
ON LEFT(a.rollnumber, LEN(a.rollnumber)-4) = b.rollnumber COLLATE DATABASE_DEFAULT
答案 1 :(得分:0)
像这样。
update b
set rollID = a.rollID
from [dbo].[dbo_Roll] a
inner join [evt_Building Permits] b
on LEFT(a.rollnumber, LEN(a.rollnumber)-4) = b.rollnumber COLLATE DATABASE_DEFAULT
答案 2 :(得分:0)
试试这个语法:
update b
set b.roll_id = a.rollID
from [dbo].[dbo_Roll] a
inner join [evt_Building Permits] b
on LEFT(a.rollnumber, LEN(a.rollnumber)-4) = b.rollnumber COLLATE DATABASE_DEFAULT