旧访问更新声明

时间:2013-07-22 07:55:33

标签: sql sql-server oracle ms-access sql-update

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

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

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]));

提前感谢任何答案。

2 个答案:

答案 0 :(得分: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]));

答案 1 :(得分:1)

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