我打算在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