Does sp_recompile recompiles referenced objects?

  • For example we have a stored procedure SP1 and it selects from a table-valued function TVF1.

    If I run sp_recompile SP1, does it set TVF1 to be recompiled on next execution as well? Or should I specifically run sp_recompile TVF1 too?

    Thanks

  • no, it does *not* mark downstream objects to be recompiled too!

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • SQL Guy 1 wrote:

    Or should I specifically run sp_recompile TVF1 too?

    Yes, recompile the table / view rather than individual proc(s).

    If you recompile a proc, only that specific proc gets recompiled.  If you recompile a table or view, all objects that use that table/view will be recompiled.

    SQL DBA,SQL Server MVP(07, 08, 09) "Money can't buy you happiness." Maybe so, but it can make your unhappiness a LOT more comfortable!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply