0

我正在更新多个字段,并且我的查询可以正确运行每个语句,但在进入下一行时会出错。我注释掉前面的行并重新运行并在下一行运行语句和错误。
IE

UPDATE mydb
    SET VendorMPD = replace(VendorMPD,'VENDOR Campaign MPD - ','');
    SET VendorMPDHalf = replace(VendorMPDHalf,'Vendor MPD 1/2 Count - ','');
    SET DieselMPD = replace(DieselMPD,'Diesel Pumps - ','')

它每次生成的错误:

[Err] 42000 - [SQL Server]Incorrect syntax near '='.

我昨天做得很好,但需要添加额外的字段,当我这样做时,这就是开始发生的事情。我查看了我输入的新语句,除了字段名称和它们要替换的内容。编码是相同的。

4

1 回答 1

0

尝试使用以下语法在单个语句中更新多个列:

UPDATE mydb
SET VendorMPD = replace(VendorMPD,'VENDOR Campaign MPD - ',''),
    VendorMPDHalf = replace(VendorMPDHalf,'Vendor MPD 1/2 Count - ',''),
    DieselMPD = replace(DieselMPD,'Diesel Pumps - ','');
于 2013-07-11T16:17:17.247 回答