How to obtain list of queries executed on SQL Server

  • Hi,

    I have binary executable that is executing queries against my database. I am trying to get a list of queries being sent by this binary to my SQL server. Does anybody have any recommendations on how to go about it?

    Thanks,

    Mo

  • you can run a profiler and check for hostname,application name etc

    Or

    select qs.SPID,user_name(qs.spid),qs.BLOCKED,qs.WAITTYPE,qs.DBID,qs.CPU,qs.PHYSICAL_IO,

    qs.LOGIN_TIME,

    qs.LAST_BATCH,

    qs.STATUS,

    qs.HOSTNAME,PROGRAM_NAME,

    qs.HOSTPROCESS,CMD,

    qs.NT_DOMAIN,

    qs.NT_USERNAME,

    qs.NET_LIBRARY,

    qs.LOGINAME,object_name(ec.objectid,qs.dbid) as objectid,ec.text as SQLTEXT

    from master.sys.sysprocesses AS qs

    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) ec

  • Please don't cross post.

    Also asked (and answered) here:

    http://www.sqlservercentral.com/Forums/Topic534754-1291-1.aspx

    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

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

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