我打算在SqlServer中編寫一個可以更新連接表的程序,在我的情況下,我有兩個表(HowzeEducation & HowzeDegree),所以我寫了下面的查詢,但它有錯誤,並且無法正常工作。這裏是我的代碼:如何更新兩個連接表?
declare
@HowzeEducationId int,
@DegreeId int,
@FieldName nvarchar(50),
@FinishLevelDate date,
@Average decimal(4,2),
@SchoolName nvarchar(50),
@StudyCityDescribtion nvarchar(100),
@ThesisTitle nvarchar(200),
@Describtion nvarchar(600)
update (
select he.FieldName,
he.Average,
he.Describtion,
he.FinishLevelDate,
he.SchoolName,
he.StudyCityDescribtion,
he.ThesisTitle,
hd.DegreeId
from HowzeEducation he inner join HowzeDegree hd on
he.HowzeEducationId=hd.HowzeEducationId
)
set [email protected] ,
[email protected],
[email protected],
[email protected],
[email protected],
[email protected],
[email protected],
[email protected]
where [email protected]
如何解決這個問題?
你可以照顧發佈錯誤嗎? –
'UPDATE'語句(或'INSERT'或'DELETE')只能影響一(1)個表。你必須把它寫成2'UPDATE'。 –
爲什麼不使用事務來更新這兩個表。 – TaeV