Is there any easy way to find out how many times a function is called in a procedure

  • I also need to find out how often the function is used on the server

  • Run a server-side trace

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • If the function is embedded in other statements you'll probably need to generate the list of places where it's used and then run the server-side trace as Gail suggested, looking for the places where it is used in addition to looking for it.

    "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

  • just increment a value in a table whenever the function is executed.

    The probability of survival is inversely proportional to the angle of arrival.

  • sturner (10/18/2010)


    just increment a value in a table whenever the function is executed.

    Functions are not allowed to cause side-effects. They cannot insert, update or delete from permanent or temporary tables.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I was referring to adding a simple update statement in-line at the point of execution.

    Obviously if it is called from many different locations (or dynamically generated SQL) he'll have to go with a trace.

    The probability of survival is inversely proportional to the angle of arrival.

Viewing 7 posts - 1 through 6 (of 6 total)

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