0

我收到错误:

(消息 102,级别 15,状态 1,第 1 行“I”附近的语法不正确。)执行 SQL 查询时。

如果我在任何地方错了,请告诉我。

UPDATE tbl_Item I
LEFT JOIN  tbl_Batch B ON  I.Batchuid = B.Batchuid 
LEFT JOIN  tbl_ICLExtCashLetter C ON  B.ICLExtCashLetterUID =  C.ICLExtCashLetteruid
LEFT JOIN  tbl_ICLExtFile F ON F.ICLExtFIleUId = C.ICLExtFileUId
Set MarkICLDone = 0
WHERE F.FileName = @FileName 
  1. tbl_ICLExtFile (PK) = Tbl_ICLExtCashletter (FK) 与 ID
  2. tbl_ICLExtCashletter (PK) = tbl_Batch (FK) 带 ID
  3. tbl_Batch (PK) = tbl_Item(FK) 与 ID
4

1 回答 1

4

您在使用 SQL Server 时使用 MySQL 语法进行更新。我假设您已经设置了变量的值 @FileName。SQL Server 多表连接更新的语法如下所示。

UPDATE I
Set MarkICLDone = 0
FROM   tbl_Item I     
LEFT JOIN  tbl_Batch B 
   ON  I.Batchuid = B.Batchuid 
LEFT JOIN  tbl_ICLExtCashLetter C 
   ON  B.ICLExtCashLetterUID =  C.ICLExtCashLetteruid
LEFT JOIN  tbl_ICLExtFile F 
   ON F.ICLExtFIleUId = C.ICLExtFileUId

WHERE F.FileName = @FileName 
于 2013-10-04T05:23:43.040 回答