sql - 更新查询错误 : Incorrect syntax near '='

标签 sql sql-server

尝试运行简单的更新查询,但在第 5 行抛出以下错误

update t3
set t3.Act_Flg = 'N', t3.ActiveEndDate = getdate()
from dbo.STG_EmployeeMaster_TEMP t3 
inner join dbo.TEMP_EmployeeMaster t1 on t3.GPN = t1.GPN, t3.Name = t1.Name
where t1.RecordChangedFlag = 'Y' 

它抛出一个错误:

Incorrect syntax near '='.

我不明白哪里出错了?

最佳答案

使用“与”。

update t3
set t3.Act_Flg='N', t3.ActiveEndDate=getdate()
from dbo.STG_EmployeeMaster_TEMP t3 INNER join dbo.TEMP_EmployeeMaster t1
on t3.GPN=t1.GPN and
t3.Name = t1.Name
where t1.RecordChangedFlag='Y' 

关于sql - 更新查询错误 : Incorrect syntax near '=' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38445804/

相关文章:

C# 错误 : Index was outside the bounds of the array

sql-server - MDX 过滤器表达式理解

mysql - 在 Mysql 中标记旧的重复项

java - 如何使用 jOOQ 从模板生成带有参数顺序的 SQL?

sql - 临时数据库如何工作?

sql - 使用一个查询增加具有 UNIQUE 约束的字段中的一组值,Postgres

c# - 哪个数据库最适合单用户和只读模式

mysql - LOAD DATA LOCAL INFILE 跳过行而不发出警告

php - 这安全吗? ADOdb 准备语句

SQL 查询删除与两个不同数据库的 3 个表内部连接中的重复值