1

这个 SQL 语句出了什么问题,我找不到任何错误

UPDATE Master_Adjust 
    INNER JOIN [dbo].[Master] ON Master_Adjust.Empno = [dbo].[Master].Empno  
                         SET Master_Adjust.GratuityYtodate = [dbo].[Master].GratuityYtodate,  
                             Master_Adjust.ManualBasicPay = 0, 
                             Master_Adjust.ManualTax = 0,
                             Master_Adjust.ManualNapsa = 0,
                             Master_Adjust.ManualPension = 0,
                             ManualCharity = 0 

错误消息是

Msg 156, Level 15, State 1, Line 2

Incorrect syntax near the keyword 'INNER'.

4

3 回答 3

7

看起来都错了。试试这个:

 UPDATE ma
 SET ma.GratuityYtodate = [dbo].[Master].GratuityYtodate,  
     ma.ManualBasicPay = 0, 
     ma.ManualTax = 0,
     ma.ManualNapsa = 0,
     ma.ManualPension = 0,
     ManualCharity = 0 
 FROM Master_Adjust as ma
 INNER JOIN [dbo].[Master] ON ma.Empno = [dbo].[Master].Empno  
于 2013-05-14T14:29:38.723 回答
1

那不是 t-sql 语法。尝试:

UPDATE ma

                         SET ma.GratuityYtodate = M.GratuityYtodate,  
                             ma.ManualBasicPay = 0, 
                             ma.ManualTax = 0,
                             ma.ManualNapsa = 0,
                             ma.ManualPension = 0,
                             ma.ManualCharity = 0 
from  Master_Adjust ma
INNER JOIN [dbo].[Master] m ON ma.Empno = M.Empno  
于 2013-05-14T14:28:24.823 回答
0

尝试以下查询。

UPDATE [dbo].Master_Adjust 
SET 
   Master_Adjust.GratuityYtodate = [dbo].[Master].GratuityYtodate
  ,Master_Adjust.ManualBasicPay = 0
  ,Master_Adjust.ManualTax = 0
  ,Master_Adjust.ManualNapsa = 0
  ,Master_Adjust.ManualPension = 0
  ,ManualCharity = 0 
 from
    [dbo].[Master]
INNER JOIN
    [dbo].Master_Adjust 
ON
    [dbo].Master_Adjust.Empno = [dbo].[Master].Empno 
于 2013-05-15T15:00:50.833 回答