how to check which user most using table and script

Lily June 101 Reputation points
2021-12-09T07:12:56.21+00:00

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.
13,361 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,601 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AmeliaGu-MSFT 13,971 Reputation points Microsoft Vendor
    2021-12-09T09:17:20.513+00:00

    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.
    156179-image.png
    And we can check the Save to table option in the General tab to select the table for trace.

    156180-image.png

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

    Best Regards,
    Amelia


    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