• Luis Cazares (2/4/2014)


    I don't know your complete requirements, but shouldn't you be showing a lot less rows (just one per cart)? If you just want to list the Carts with Maintenance, you should avoid the inner join and try something like IN or EXISTS. If you don't care to show Carts even if a Cart doesn't have Maintenance, then you don't even need that.

    In the FROM statement in the main stored procedure, I'm joining Cart with #maintType like this:

    LEFT JOIN #MaintType AS mt on c.CartID = mt.CartID

    Is it possible to eliminate the inner join from my SELECT? I was thinking I needed it, but it's entirely possible I'm missing something :Whistling:

    The main stored procedure pulls info on almost every cart (exceptions are ones created purely for testing purposes). I noticed there are duplicates in the above select, but a 'SELECT DISTINCT' takes care of those (leaving 1446 rows).

    In the FROM statement in the main stored procedure, I'm joining Cart with #maintType like this:

    LEFT JOIN #MaintType AS mt on c.CartID = mt.CartID

    Is it possible to eliminate the inner join?

    I'd forgotton to include this in the first post, but the Cart table has ~5100 rows.

    Luis CazaresThe sort is explicitly defined by the order by in your query when you build your comma separated value.

    The sort is not the problem, as you need it (and if you don't, just remove it).

    Someone else might be able to go further with advices on DDL, but these are my 2 cents. 😉

    Thanks for the reply.