Cross Database Queries

  • Please advice what can i use to trace cross database queries.

    What i mean is, say a login XYZ can access multiple databases. If XYZ connects to database ABC and executes a tsql which is joining a table from database PQR, how can i capture these queries and report on it?

    Any help is appreciated.

  • not sure if this is the best way but i'd look to trace the user(s) and at the end of each day import the trace file into a table and look to scan the text for the databases you want to track.

    It may be possible to track via extended events but i'm no expert in that area.

    _________________________________________________________________________________SQLGeordieWeb:- Jarrin ConsultancyBlog:- www.chrisjarrintaylor.co.ukTwitter:- @SQLGeordie

  • If you setup a trace to capture the SQL:BatchCompleted event with the TextData column and add a filter on only the login name, i.e. do not add a filter on the database name, the trace will capture the activity and you will see the SQL issued in the TextData column.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Anam Verma (3/5/2012)


    Please advice what can i use to trace cross database queries.

    What i mean is, say a login XYZ can access multiple databases. If XYZ connects to database ABC and executes a tsql which is joining a table from database PQR, how can i capture these queries and report on it?

    Any help is appreciated.

    Are these databases on the same instance of SQL Server?

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

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

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