Runing some SQL statment inside stored procedure and out side stored procedure

  • I have some sql statment,which when I run it individually they are pretty fast,but when I put them inside a stored procedure and execute the stored procedure.It is very slow.We are using SQL SERVER 2008.Should I do anything special about the SP?Something like compiling?Because I am running the exact code inside and outside of stored procedure

  • The stored procedure gets compiled at run time (and then cached), the same as running individual statements. There should be no difference in performance between the two, or at least nothing noticeable by a human.

    I'd be willing to bet it's something like parallelism kicking in and causing issues, blocking, or some other outside factor.

  • Sounds like parameter sniffing[/url]. Please follow the link and read all three related articles. It's well worth it!



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

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

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