2

这以前有效,但现在不起作用,我很困惑。我回顾了整个事情,一切看起来都很好,但也许更高级的人可以发现一些东西?

这是脚本:

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 太陌生了,无法识别它。谢谢

4

3 回答 3

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'
于 2012-07-17T18:28:56.107 回答
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'

或者如果您也发布错误会很好

于 2012-07-17T18:30:37.473 回答
0

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,转换(char(10),getdate(),101))和 Orders.Shipped = 'Y'

于 2012-07-19T17:05:50.900 回答