我已经厌倦了看到这个错误:
消息102,级别15,状态1,过程sp_reorder_quantity,第16行
“ - ”附近的语法不正确。
它说明了这一点,因为它在第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
答案 0 :(得分:5)
这可能只是自动格式化,但–
(“en dash”,U + 2013)与-
不是同一个字符(“连字符 - 减号”,U + 002D)。
尝试将其更改为:
WHERE products.quantity_in_stock - products.reorder_level < @unit;
如果我把它们放在彼此旁边,这更容易看出:
WHERE products.quantity_in_stock – products.reorder_level < @unit; -- yours
WHERE products.quantity_in_stock - products.reorder_level < @unit; -- fixed
答案 1 :(得分:0)
您可以随时将该行改为:
WHERE products.quantity_in_stock < products.reorder_level + @unit;