how to check which user most using table and script

Lily June 101 Reputation points

I have 3 databases in one sql server.Some of database's tables sometime too much take time when select query ,sometime it's normal that why I would like to know why too much take time which user are querying.
Here's my sample query

select customername from Customer where customerid='1002798469'

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,239 questions
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,515 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AmeliaGu-MSFT 13,956 Reputation points Microsoft Vendor

    Hi LilyJune-5583,

    Do you mean you want to check who used these tables and how long it took for users to run queries?
    You can use the SQL Server Profiler to create a trace with event such as SQL:BatchCompleted, SQL:BatchStarting, SQL:StmtCompleted and SQL:StmtStarting to capture the users and queries run by users.

    We can specify a filter to monitor the specific database in Event Selection tab->column Filters.
    And we can check the Save to table option in the General tab to select the table for trace.


    Please refer to this article and this doc which might be helpful.

    Best Regards,

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments