Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2011
    Posts
    22

    Question Unanswered: How to know what scripts an Application sent to DB?

    I support an old VB6 application that executes SQL queries or Stored Procedures on our SQL Server. I know that you can go to the Activity Monitor and pull up Recent Expensive Queries, but apparently the query I'm interested in examining isn't "expensive" enough.

    Our application is displaying data based on the output of some query, and I'd like to know what that query is... cause the data it is displaying differs from another set of data displayed someplace else in the application. I can reproduce the numbers displayed in the second location, but I'm wanting to know how the application is coming about creating the data for the first location.

    How can this be done?

    Trying to save a case from needing to go to Engineering, as I'm sure this is just a data issue and not an issue with the application.

  2. #2
    Join Date
    Aug 2004
    Location
    Dallas, Texas
    Posts
    831
    Have you tried profiler? I can capture the sql and put it in ssms to execute plan.

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    As corncrowe pointed out Microsoft SQL Profiler ought to be just what you need. Start a profile trace, run the interesting code, then stop the trace... Depending on the settings, it can show you everything you might possibly want to know about what commands the SQL Server received and what output it returned!

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  4. #4
    Join Date
    Aug 2004
    Location
    Dallas, Texas
    Posts
    831
    Well said, sir!

  5. #5
    Join Date
    Jul 2011
    Posts
    22
    Thank you, your information was helpful. I'm now using Profiler for a lot of the troubleshooting I've been doing for the past two weeks. Very useful tool, that I'd not had to use before.

    Thanks again =)

  6. #6
    Join Date
    Aug 2004
    Location
    Dallas, Texas
    Posts
    831
    Quote Originally Posted by James_A View Post
    Thank you, your information was helpful. I'm now using Profiler for a lot of the troubleshooting I've been doing for the past two weeks. Very useful tool, that I'd not had to use before.

    Thanks again =)
    Of course, you could also write a script that examines sprocs that are executing (sys.processes):

    Create a new table to hold results
    Create script to check for system processes where sproc (type)
    Insert script attributes into table
    Create script to query table for results specific to what you require
    I have a few custom scripts that does what profiler can do with lots of tweaks. Once you understand the db engine and components it is easier to grind out good data with customer scripts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •