Stored procedure

  • Hi all,

    I want to modify the existing stored procedure . What is the process and how can i know the new one is better than the old one.

    I mean like query tuning is there way we can see how effective is that stored procedure

  • Write it and test it. Tweak it and test it. Tweak some more and test it. test test test.

    ---------------------------------------------------------------
    Mike Hahn - MCSomething someday:-)
    Right way to ask for help!!
    http://www.sqlservercentral.com/articles/Best+Practices/61537/
    I post so I can see my avatar :hehe:
    I want a personal webpage 😎
    I want to win the lotto 😀
    I want a gf like Tiffa :w00t: Oh wait I'm married!:-D

  • Stored procedure tuning is the same as query tuning. You measure the performance of the procedure, in terms of time to execute, logical reads and CPU. You make modifications to the procedure or the structures that the procedure calls, then you measure again. Repeat as necessary. Follow the link to my book. I detail this process and more.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Try this way, comment the create procedure line using declare give values to the parameters and run it as query and now you can check the place where you made changes and execute the temp tables and the logic query on the same query tab in such way you can know which query is taking more time and why.

    The other way is use SQL profiler.

  • devaji123 (2/12/2013)


    Try this way, comment the create procedure line using declare give values to the parameters and run it as query and now you can check the place where you made changes and execute the temp tables and the logic query on the same query tab in such way you can know which query is taking more time and why.

    The other way is use SQL profiler.

    Just know that if you're passing values to the parameters locally, as variables, it changes the way the procedure will be resolved because the optimizer will not be able to sniff the local variables in the same way it can parameters. In general, I wouldn't recommend this approach. Just call the procedure and pass it the parameters you want.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 5 posts - 1 through 4 (of 4 total)

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