Home Forums SQL Server 2008 T-SQL (SS2K8) join/merge 2 status tables (check statuses at any change) RE: join/merge 2 status tables (check statuses at any change)

  • Hi All,

    First of all - Big Thanks for all your input (and good words for newbie as well:).

    @Nevyn - thanks for your solution, but as you yourself suggested - it's quite complicated and I also wonder about performance.

    If possible I try to keep my code as simple as possible (unless performance requires to make it more complicated), as it is possible that some other people will work on that code and they need to understand fast.

    @alan.B. - I'm happy you liked my way - I'm starting to see it's not that bad at all:)

    1. UNION - I feel so stupid - I always thought that union leaves the doubles in first query and removes those from the next.

    I just checked and (of course you're right). thanks for that:)

    2. those were just for example. But as I work in ETL and DWH it happens to me a lot to get the tables with SQL Words in names.

    3. I have to check the performance with clustered index. But it won't be that much of a problem, as the table isn't really that big (so again I will take cleaner code if the performance isn't the issue).

    @Dwain.C

    1. quirky update - I've seen it before. I didn't know the name. it's a great article you've sent me. Especially why one should use maxdop(1) and tablockx.

    2. full outer join vs union all - yep. I've just noticed it. It could also happen that the same status type could change more than one time during a day. But I gues I would have to filter those somehow first...

    3. I know there's lag/lead in sql 2012. I'm doing it on SQL 2008r2 so no go.

    4. DDL - it's just something I've seen in many post. Obviously if you want somebody's help, you need to make it as simple as possible.

    btw. out of 4 forums I've sent the same request, this is were I got the best responses.

    Thanks again.