• Not much to go on here, but first thing I would do is put OPTION (RECOMPILE) on that big mess of a query. If that isn't a repeatable magic bullet to keep you at the 25 minute run time then you will likely have to go in and break the big query down into one of more temporary table-based (NOT table variable) intermediate result sets. I have done this over and over for clients to often pick up 3-5 orders of magnitude performance improvements PLUS gain normalcy on the execution times. You may wish to do this anyway because that 25 minutes may only need to be 3 minutes!

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service