--批量执行存储过程
SELECT ROW_NUMBER() over(ORDER BY bo.orderno) RowNumber, bo.OrderNo,bo.OrderStatus INTO #aaa
FROM bdOrder bo
JOIN mdDepartment md ON bo.DepartmentID=md.ID
JOIN mdDepartment MD2 ON md.OrganID LIKE MD2.OrganID+'%'
AND md2.ID=16
AND bo.OrderDate>'2012-02-28'
AND bo.OrderStatus IN('02','03')
DECLARE @rowNo INT ,@MaxRow INT,@OrderNo VARCHAR(50),@str VARCHAR(MAX)
SELECT @rowNo=1,@MaxRow=MAX(RowNumber)+1 FROM #aaa
SELECT @str=''
WHILE(@rowNo<@MaxRow)
BEGIN
SELECT @OrderNo=OrderNo FROM #aaa WHERE RowNumber=@rowNo
EXEC bdAllocateOrder_data @TranType='GetAddAllocateOrder',@OrderNo=@OrderNo
select @rowNo=@rowNo+1
END