我太累了,看到這個錯誤的表達:在上下文指定的非布爾類型了條件,預計
Msg 102, Level 15, State 1, Procedure sp_reorder_quantity, Line 16
Incorrect syntax near '–'.
它指出這一點,因爲在那裏指出第16行:
WHERE products.quantity_in_stock – products.reorder_level < @unit;
這就是說products.quantity_in_stock
是:An expression of non-boolean type specified in a context where a condition is expected
。
CREATE PROCEDURE sp_reorder_quantity
(
@unit int
)
AS
SELECT
products.product_id,
suppliers.name,
suppliers.address,
suppliers.city,
suppliers.province,
'qty' = products.quantity_in_stock,
products.reorder_level
FROM
suppliers
INNER JOIN
products ON suppliers.supplier_id = products.supplier_id
WHERE
products.quantity_in_stock – products.reorder_level < @unit;
GO
哦,我的。對,就是這樣......我從電子郵件中複製了該行。謝謝! – isolatedhowl