• First I would see if the query returns anything when you replace

    o.StatusID in (Select osl.val from dbo.SplitStringToIntegerArray(@OrderStatusList, ',') osl ) and

    o.OrderTypeID = 1

    with

    where o.OrderTypeID = 1

    If you you get rows then you know the problem is with your dbo.SplitStringToIntegerArray result set; StatusID does not exist in (Select osl.val from dbo.SplitStringToIntegerArray(@OrderStatusList, ',') osl ).

    Build the @OrderStatusList variable and run your splitString query against that variable only. Make sure that something it is returning something. Then run your stored proc and compare the StatusID values returned against the results of the splitstring query. That's what I would do.

    BTW, if you are looking for a splitter, use the one by Jeff Moden mentioned in my signature line. You will find that it makes short work of the XML splitter you are using. You also may want to consider losing those nolock table hints if your data absolutely has to be accurate.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001