create procedure DeleteProductID @productid int = NOTNULL, @forceDelete int, @posCount int as select * from Sales.OrderDetails if @forceDelete = 1 delete from Sales.OrderDetails where orderid = @productid else if @forceDelete = 0 delete from Sales.OrderDetails where count(productid) < @posCount go
Msg 147, Level 15, State 1, Procedure DeleteProductID, Line 11 [Batch Start Line 0] An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.
declare @CountOrderId int select @CountOrderId = count(productid) from Sales.OrderDetails group by productid create procedure DeleteProductID @productid int = NOTNULL, @forceDelete int, @posCount int, as select * from Sales.OrderDetails if @forceDelete = 1 delete from Sales.OrderDetails where orderid = @productid else if @forceDelete = 0 delete from Sales.OrderDetails where @CountOrderId < @posCount
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)