0

我们最近从 Oracle 切换到 SQL Server,我们有这个旧的更新语句,它曾经可以工作,但现在给出错误“操作必须是可更新的查询”。那么查询类型设置为更新,我尝试以管理员身份运行它没有成功,我们能够运行选择语句没有问题,所以连接一定没问题吗?

我不确定我是否只是错过了一些非常简单的东西,因为我习惯于在 SSMS 而不是 Access 中工作。更新语句的代码如下:

UPDATE dbo_LEARNER_AIMS 
INNER JOIN dbo_REGISTRATION_UNITS ON dbo_LEARNER_AIMS.RUL_CODE = dbo_REGISTRATION_UNITS.RUL_CODE 
SET dbo_LEARNER_AIMS.END_DATE = [EXP_END_DATE], 
dbo_LEARNER_AIMS.COMPLETION = "10", 
dbo_LEARNER_AIMS.OUTCOME = "40", 
dbo_REGISTRATION_UNITS.FES_PROGRESS_CODE = "EXT", 
dbo_REGISTRATION_UNITS.FES_PROGRESS_DATE = [EXP_END_DATE], 
dbo_REGISTRATION_UNITS.PROGRESS_STATUS = "X"
WHERE (((dbo_LEARNER_AIMS.END_DATE) Is Null)
AND ((dbo_LEARNER_AIMS.FUNDING_YEAR)="17")
AND ((dbo_LEARNER_AIMS.LEARNING_AIM) = [Enter Aim])
AND ((dbo_LEARNER_AIMS.EXP_END_DATE) Between #8/1/2012#
AND [enter expected end date]));

提前感谢任何答案。

4

2 回答 2

1

试试这个查询:

UPDATE dbo_LEARNER_AIMS 

SET END_DATE = [EXP_END_DATE], 
COMPLETION = "10", 
OUTCOME = "40", 
/*
dbo_REGISTRATION_UNITS.FES_PROGRESS_CODE = "EXT", 
dbo_REGISTRATION_UNITS.FES_PROGRESS_DATE = [EXP_END_DATE], 
dbo_REGISTRATION_UNITS.PROGRESS_STATUS = "X"

You can't update multiple table in one update statement ! */

FROM dbo_LEARNER_AIMS  /* add this line */
INNER JOIN dbo_REGISTRATION_UNITS ON dbo_LEARNER_AIMS.RUL_CODE = dbo_REGISTRATION_UNITS.RUL_CODE 

WHERE (((dbo_LEARNER_AIMS.END_DATE) Is Null)
AND ((dbo_LEARNER_AIMS.FUNDING_YEAR)="17")
AND ((dbo_LEARNER_AIMS.LEARNING_AIM) = [Enter Aim])
AND ((dbo_LEARNER_AIMS.EXP_END_DATE) Between #8/1/2012#
AND [enter expected end date]));
于 2013-07-22T08:04:51.537 回答
1

错误“操作必须是可更新的查询”。
几乎总是意味着索引问题,通常是缺少主键。还要检查查询的属性页面,查找 Snapshot vs Dynaset 设置。

于 2013-07-22T16:26:28.250 回答