• thenewbee (7/30/2015)


    Sorry but its something like this

    with wftbl(

    select col1,..col5 from objectA

    inner join objectB

    on cond1 =cond1

    where ...

    )

    ....

    tbl2(

    object c

    inner join

    objectA

    where . ..

    )

    select col1 .. .

    from

    maintabl

    ....

    left join (select * from objectA where condtn)worktbl

    ...

    left join objectA

    on (worktbl.id = objectA.ID AnD worktbl.order >1000)

    OR

    (worktbl.anotherid = objectA.ID AnD worktbl.order =1000)

    left join

    ....

    You showed everything except for any details about the query. Performance problems are often in things like where predicates. We can help but you are going to have to provide some details. The actual query, table definitions and index definitions along with the actual execution plan. Without these details we can't possibly help. Please take a look at this article for some details about how to find and post this information. http://www.sqlservercentral.com/articles/SQLServerCentral/66909/[/url]

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/