Original Post
Using SQL Server 2000 is there an easier way to do this? Part of this is going to my own psuedocode, but the bulk is TRANSACT-SQL Before someone suggests cursors, I figured a cursor would be really slow.. What i am really looking for is a single select query that will get me the same results. FOREACH(@idorder in OrdersTable) { DECLARE @filledcount smallint DECLARE @orderrows smallint SELECT @filledcount = count(idorderdetails) FROM orders_details , products WHERE products.idproduct = orders_details.idproduct AND ISNULL(quantity,0) <= ISNULL(received,0) + ISNULL(stock,0) and idorder = @idorder select @orderrows = count(idorderdetails) from orders_details where idorder = @idorder }