之前有效,但现在它不起作用,我很困惑。我回顾了整个事情,一切看起来都不错,但也许更先进的人可以发现一些东西?
这是脚本:
UPDATE Orders SET Orders.OrderStatus = 'Shipped',Orders.SalesRep_CustomerID = null
WHERE Orders.OrderStatus in ('Pending','Processing')
AND Orders.PaymentAmount = Orders.Total_Payment_Received
AND Orders.ShipDate < dateadd(day, -60, convert(char(10), getdate(), 101))
AND Orders.Shipped = Y
我得到的只是一个错误,没有解释。有人可以发现一个错误,我确信很明显我对SQL来说太新了以至于无法识别它。感谢
答案 0 :(得分:6)
不确定您收到的错误是什么,但您需要在引号中加上Y.
UPDATE Orders SET Orders.OrderStatus = 'Shipped',Orders.SalesRep_CustomerID = null
WHERE Orders.OrderStatus in ('Pending','Processing')
AND Orders.PaymentAmount = Orders.Total_Payment_Received
AND Orders.ShipDate < dateadd(day, -60, convert(char(10), getdate(), 101))
AND Orders.Shipped = 'Y'
答案 1 :(得分:2)
最后一行中的Y必须位于''
中UPDATE Orders SET Orders.OrderStatus = 'Shipped',Orders.SalesRep_CustomerID = null
WHERE Orders.OrderStatus in ('Pending','Processing')
AND Orders.PaymentAmount = Orders.Total_Payment_Received
AND Orders.ShipDate < dateadd(day, -60, convert(char(10), getdate(), 101))
AND Orders.Shipped = 'Y'
如果你发布错误也会很好
答案 2 :(得分:0)
UPDATE订单SET Orders.OrderStatus ='Shipped',Orders.SalesRep_CustomerID = null 在哪里Orders.OrderStatus('待定','处理') AND Orders.PaymentAmount = Orders.Total_Payment_Received AND Orders.ShipDate&lt; dateadd(day,-60,convert(char(10),getdate(),101)) AND Orders.Shipped ='Y'