SQL存储过程基础语法问题,不知道用啥符号~
CREATE PROCEDURE [月统计]
(
@Year [nvarchar](4),
@Month [nvarchar](2),
@ClassID [int]
)
AS
SELECT SUM(dbo.Order_Product.OP_Price * dbo.Order_Product.OP_ProductNumber)
FROM dbo.Product_Class INNER JOIN
dbo.Product_List ON
dbo.Product_Class.PC_ID = dbo.Product_List.PL_ClassID INNER JOIN
dbo.Order_Product ON
dbo.Product_List.PL_ID = dbo.Order_Product.OP_ProductID
WHERE ( ', ' + dbo.Product_Class.PC_ParentIDs + ', ' LIKE '%@ClassID% ') AND
(LEFT(dbo.Order_Product.OP_OrderID, 4) = @Year) AND (CONVERT(int,
SUBSTRING(dbo.Order_Product.OP_OrderID, 5, 2)) = @Month)
GO
就是
( ', ' + dbo.Product_Class.PC_ParentIDs + ', ' LIKE '%,@ClassID,% ')
这个参数~本来应该是这样的~
( ', ' + dbo.Product_Class.PC_ParentIDs + ', ' LIKE '%,111,% ')
可是我不知道怎么连……这样子是不行的吧?取出来是空值~
[解决办法]
LIKE '% '+@ClassID+ '% '
[解决办法]
LIKE '% ' + @ClassID + '% '
[解决办法]
SELECT SUM(dbo.Order_Product.OP_Price * dbo.Order_Product.OP_ProductNumber)
FROM dbo.Product_Class INNER JOIN
dbo.Product_List ON
dbo.Product_Class.PC_ID = dbo.Product_List.PL_ClassID INNER JOIN
dbo.Order_Product ON
dbo.Product_List.PL_ID = dbo.Order_Product.OP_ProductID
WHERE (dbo.Product_Class.PC_ParentIDs LIKE '% ' + @ClassID + '% ') AND
(LEFT(dbo.Order_Product.OP_OrderID, 4) = @Year) AND (CONVERT(int,
SUBSTRING(dbo.Order_Product.OP_OrderID, 5, 2)) = @Month)