When is a function used

  • Hello,

    Please can you tell me if I can and how can I see the usage of a function?

    I mean... I want to know how many times is a certain (or all) function used.

    Wish you good ideas! 🙂
    Andreea

  • Because on the production db the compatibility level is 80, I have run on master database (90) the query below that does almost what I wanted...

    SELECT

    sql.dbid

    sql.text

    max(s.last_execution_time)[LastExecDate],

    sql.objectid [ObjectId],

    count(*) [Total]

    FROM sys.dm_exec_query_stats s

    CROSS APPLY sys.dm_exec_sql_text(s.sql_handle) sql

    WHERE

    sql.dbid IN (5)

    GROUP BY sql.dbid ,sql.text,sql.objectid

    ...

    Wish you good ideas! 🙂
    Andreea

  • The best way to monitor object useage is through a Profiler Trace. Server-side is more efficient that GUI version, but either works. Filter your trace to look only for the object_id of that function and you should be able to get a good gauge for how many times across the day it's called.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

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

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