Using LIKE in stored proc parameter
Posted on 2008-06-23
I have a dynamic query that I made into a stored procedure using parameters in SQL Server 2005...
SELECT count(*) as [Count]
FROM [Orders] o
left join [order_detail] od
on o.Order_ID = od.Order_ID
where o.sold_to_customer_PO_ref like @OrderNumber + '%' and od.SKU = @SKU and (o.Order_Status = 'Hold' or o.Order_Status = 'OKAY')and o.carrier_code <> 'CANCEL'
So, here is my problem, I pass in the order number and sku when I execute the proc, like so:
EXEC sp_GetOrderCount '3200112', '883575550329'
But the procedure returns a count of 0. When I just run the query (like listed above), I get an accurate count of 4.
What's wrong with my proc?
Thanks in advance!