HOW TO TRACK ALL QUERY IN A DATABASE IN A TABLE FORMAT

  • DEAR ALL,

    HOW CAN I TRACE ALL THE QUERIES WHICH IS RUN IN NEW QUERY WINDOW AND IT AUTOMATICALLY INSERT

    INTO A TABLE IN ROW AND COLUMN FORMAT.

    EXAMPLE-IF I AM WRITING SELECT ,UPDATE,DELETE,INSERT ETC QUERY

    THE QUERY WHICH IS RUN WILL SAVE INTO A TABLE BY COLUMN

    USER NAME-> LOGIN NAME

    USER MACHINE NAME-> INSTANCE NAME OR PC NAME EG-IVAN-PC,RTM,

    QUERY RUN TIME- > WHEN THE QUERY HAS BEEN RUN.

    THE ENTIRE QUERY-> EG-SELECT * FROM TABLENAME.

  • Please don't post in all caps. It's like shouting at us.

    To trace queries executed you need SQL profiler or a Server-side trace. See http://qa.sqlservercentral.com/stairway/72363/

    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
  • dear sir ,

    i had gone through the link which u have provided to me but ,

    sir it is a trace where i can'nt find the query which is been run and from which machine-pc.

    sir plz read my before post carefully .

  • Ivan Mohapatra (3/9/2011)


    sir it is a trace where i can'nt find the query which is been run and from which machine-pc.

    Sorry, I don't understand what you're asking.

    If you want something to log all queries that run with the machines they run from, traces will do that. Not automatically, you have to configure them, but they most certainly can. Not straight to table (unless you want to seriously degrade performance) but to a file that you can import into a table. Please re-read the articles (all three) carefully.

    sir plz read my before post carefully .

    I did read your post completely before I answered.

    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
  • Based on what you wrote (and yes, I read it too), you have two options. First, set up a serveri-side trace as Gail has already suggested. Second, you can try to do the same thing as the server side trace using extended events.

    Frankly, you're better off with the trace, but if you're interested, here's where you can go to learn how to use extended events. Here's a sample for collecting the data.

    In the event I'm misunderstanding your question, another option is to use Mladen Prajdic's SSMS Tookpack[/url], which will store each query during a session within SQL Server so you can see what you ran as you ran it.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

  • thank you sir,

    finally i got the tool which i was searching from 3 months .

    thanks to u both.

    (thank you ) in hindi ->(Danyabad)

  • Which? Three different things were mentioned.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

  • sir i used the ssms tool which helped me a lot .

    and

    thanks

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

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