How to capture sqlscript from a specific computer while using sqlserver profiler

  • There is a web-based oa system, it has an IIS application server(OA was deployed on this IIS application server), and IIS application server accesses SQL Server database, there are many online users to use OA system at the same time, is there is a way to detect the sql script from computer A? I know if the c/s system accesses SQL server we can use hostname or ClientProcessID to filter. how to detect the SQL Script from computer A? thanks!

  • When you setup the trace in SQLProfiler, be sure to include the TextData and HostName columns.  Then, on the Events Selection tab, click on the column name and setup a filter for the exact host name.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thanks Jeff Moden for you kind help!

    but it is a web system, there are many user accessing this system thru Google browser at the same time, and Google browser access IIS application server first (as the web system is deployed on IIS application server), then IIS application server access SQL server, if I use hostname(such as computer A) to filter, the hostname of the SQL Server Profiler only shows the name of IIS application Server's name, so we can't use user's computer name to fiter, if so, is there any way to capture the sql script from my computer? thanks!

  • No you cannot get the true end users computer from profiler (or extended events for that matter) as that is not the computer connecting to SQL.

    If you want to get the true end users machine, you're going to have to put logging at the IIS level, and not the SQL level.

  • Or you need to include that information in the calls to SQL Server - as in a parameter to a stored procedure (e.g. User, UserID, etc.)

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Ant-Green wrote:

    No you cannot get the true end users computer from profiler (or extended events for that matter) as that is not the computer connecting to SQL.

    If you want to get the true end users machine, you're going to have to put logging at the IIS level, and not the SQL level.

    if I want to get the true ene users machine, how can I put logging at the IIS level? thank you !

     

  • Jeffrey Williams wrote:

    Or you need to include that information in the calls to SQL Server - as in a parameter to a stored procedure (e.g. User, UserID, etc.)

    yes , this is  a solution, but sometimes, when using SQL server profiler to trace the running SQL script, it can't the paramter's value, don't know how to get parameter value, thanks!

     

  • 892717952 wrote:

    Jeffrey Williams wrote:

    Or you need to include that information in the calls to SQL Server - as in a parameter to a stored procedure (e.g. User, UserID, etc.)

    yes , this is  a solution, but sometimes, when using SQL server profiler to trace the running SQL script, it can't the paramter's value, don't know how to get parameter value, thanks!

    To be honest, I've never seen SQL Profiler miss such things if it's done correctly on the WebServer.  When it's not done correctly on the WebServer, there's a real high probability that the code on the WebServer is prone to SQL Injection attacks.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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