由于数据库设计,我必须在一个语句中执行两个更新查询。我试过这样做并在网上查看这些例子,但无济于事。我正在使用SQL Server 2014,而且我正在使用ASP.NET MVC项目的查询。
update [sip].[StudentJournalDate] sjd
inner join [sip].[StudentJournal] sj on sjd.AdminNo = sj.AdminNo
set sj.WeekNo = @WeekNo,
sjd.WeekNo = @WeekNo,
sj.StartDateEntry = @StartDate,
sjd,StartDateEntry = @StartDate,
sjd.LastUpdatedBy = @LastUpdatedBy,
sjd.LastUpdatedDate = @LastUpdatedDate,
sjd.EndDateEntry = @EndDate
where
AdminNo = @AdminNo";
答案 0 :(得分:1)
你应该逐个更新
/*Update StudentJournalDate table*/
UPDATE [sip].[StudentJournalDate]
SET WeekNo = @WeekNo,
StartDateEntry = @StartDate,
LastUpdatedBy = @LastUpdatedBy,
LastUpdatedDate = @LastUpdatedDate,
EndDateEntry = @EndDate
WHERE
AdminNo = @AdminNo
/*Update StudentJournal table*/
UPDATE [sip].[StudentJournal]
SET WeekNo = @WeekNo,
StartDateEntry = @StartDate
WHERE AdminNo = @AdminNo
答案 1 :(得分:0)
Juan是正确的你可能想把它分成两个单独的更新语句。您可以为StudentJournal创建一个更新,并为StudentJournalDate创建一个更新。
>>> import multiprocess as mp
>>> p = mp.Pool()
>>> p.map(lambda x:x**2, range(4))
[0, 1, 4, 9]
>>>