Need to a Query

  • Hi All,

    I am new to this forum and I have the following question:

    - I need a query to get the following information from the SQL Server  2008 & 2012

    1- who logged in sql db ,  (user name)

    2- from where (system ip, system name)

    3- At what time and date

    4- What activity was performed ( for e.g. what query was executed)

    Thanks in advance

  • aznabeel - Thursday, December 21, 2017 12:12 AM

    Hi All,

    I am new to this forum and I have the following question:

    - I need a query to get the following information from the SQL Server  2008 & 2012

    1- who logged in sql db ,  (user name)

    2- from where (system ip, system name)

    3- At what time and date

    4- What activity was performed ( for e.g. what query was executed)

    Thanks in advance

    For that you will have to setup some form of trace and/or auditing to capture what you need.

    Points 1 2 and 3 can be done with a logon trigger
    Point 4 will be the tricky one, you can create a server wide DDL trigger to capture all DDL events, but for your DML you will need to start adding DML triggers to all your tables or run traces to tie back the SPID to the statement.

  • This might be easier with Extended Events on SQl Server 2012. I honestly can't recall if XE is available on 2008.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Thom A - Thursday, December 21, 2017 1:38 AM

    This might be easier with Extended Events on SQl Server 2012. I honestly can't recall if XE is available on 2008.

    It is, but unusable (no GUI and minimal events). Server-side trace will work fine for these requirements.

    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 4 posts - 1 through 3 (of 3 total)

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