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) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

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

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