2012-12-10 19 views
2

我太累了,看到这个错误的表达:在上下文指定的非布尔类型了条件,预计

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 

回答

5

这可能只是自动格式化搞乱的东西,但( “破折号”,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 
+0

哦,我的。对,就是这样......我从电子邮件中复制了该行。谢谢! – isolatedhowl

0

您可以随时改写的路线为:

WHERE     products.quantity_in_stock < products.reorder_level + @unit; 
相关问题