---
title: "How to setup a trace using SQL Profiler to monitor a specific database?"  
description: "How to setup a trace using SQL Profiler to monitor a specific database?"  
author: "Steilla Mitchel"  
published: 2024-07-16  
updated: 2024-07-18  
canonical: https://www.mindstick.com/forum/160935/how-to-setup-a-trace-using-sql-profiler-to-monitor-a-specific-database  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 5 minutes  

---

# How to setup a trace using SQL Profiler to monitor a specific database?

How to [setup](https://www.mindstick.com/articles/426/how-to-create-a-setup-project-for-windows-application) a [trace](https://www.mindstick.com/interview/1075/why-are-there-five-tracing-levels-in-system-diagnostics-traceswitcher) using SQL Profiler to monitor a specific [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax)?

## Replies

### Reply by Ashutosh Patel

#### SQL Server Profiler Trace Set-up

To set up a trace using SQL Server Profiler to monitor a specific database, follow these steps,

#### Open SQL Server Profiler

**SQL Server 2012 and later** Open SQL Server Management Studio (SSMS), then go to Tools > SQL Server Profiler.\
**For previous versions** Open SQL Server Profiler directly from the Start menu.

Here I have used SQL Server 2017 so,

![How to setup a trace using SQL Profiler to monitor a specific database?](https://www.mindstick.com/mindstickforums/1dc34331-b8f9-470f-8935-beb4727248b5/images/e5413105-f939-4373-a152-102050045bae.png)

#### Connect to the SQL Server Instance

In the SQL Server Profiler window, click **File** > **New Trace**.\
Match the SQL Server instance you want to monitor by entering the server name, authentication method, and credentials as needed.

![How to setup a trace using SQL Profiler to monitor a specific database?](https://www.mindstick.com/mindstickforums/1dc34331-b8f9-470f-8935-beb4727248b5/images/bfe792a5-750a-47dc-9582-275fe6e544bf.jpg)

#### Create a New Trace

Once you successfully login in **SQL Server Profiler** window a new pop-up window will open and you will see the "**Trace Properties**" dialog.\
Enter a name `MyTrace` for your trace in the "**Trace name**" field.

By default filled the **Trace Provider name** with the **Server name**, **Trace Provider name** with and **Version**.

Now, select **Use the template** option to **Standard (default)**, it is also selected by-default.

![How to setup a trace using SQL Profiler to monitor a specific database?](https://www.mindstick.com/mindstickforums/1dc34331-b8f9-470f-8935-beb4727248b5/images/ff3673b2-2b04-4e19-b0c6-12dd05b7b006.png)

Choose to save your trace data into a **file** or **table**, if you want to select the **Save to file** option it will ask you to save the file into the appropriate location with the Trace name **MyTrace.trc,** and it also set the maximum file size (MB), and at last check the option for **Enable file rollover.**

![How to setup a trace using SQL Profiler to monitor a specific database?](https://www.mindstick.com/mindstickforums/1dc34331-b8f9-470f-8935-beb4727248b5/images/af06df20-aa22-4f1e-a46d-a68f11a6b560.png)

If you choose the option **Save to table** it, then need to **login** then a new pop up (**Destination Table**) will open in which select **Database, Schema**, and **Table** (by default use Trace name).

**Enable the trace stop time-** By default it set the trace duration `60 minute`, if you want to set a specific date and time then uncheck the `Set trace duration` option and set a specific date from the **date** and **time** box

![How to setup a trace using SQL Profiler to monitor a specific database?](https://www.mindstick.com/mindstickforums/1dc34331-b8f9-470f-8935-beb4727248b5/images/f8f97109-2943-44a7-8f7b-4c4d097ffa1d.png)

Finally, click on `Run` button to start the trace

Here you can see the created Trace window,

![How to setup a trace using SQL Profiler to monitor a specific database?](https://www.mindstick.com/mindstickforums/1dc34331-b8f9-470f-8935-beb4727248b5/images/dcb82a24-4c5f-4777-8917-6734245ebf59.png)

Now, run below Query in SQL Database in which Trace is create

```plaintext
USE MyCollegeDb
GO
SELECT * FROM People
```

Now check again the `MyTrace` window, here you can see the SQL Query which is traced here in the below picture,

![How to setup a trace using SQL Profiler to monitor a specific database?](https://www.mindstick.com/mindstickforums/1dc34331-b8f9-470f-8935-beb4727248b5/images/5b1a6242-fce3-408f-8b04-23348784709e.png)

Now check the trace file in the folder,

![How to setup a trace using SQL Profiler to monitor a specific database?](https://www.mindstick.com/mindstickforums/1dc34331-b8f9-470f-8935-beb4727248b5/images/a8afdc49-86cc-4f5e-94f2-aaf4065abd3d.png)

Let's also check the trace table in the database `MyCollegeDb`

![How to setup a trace using SQL Profiler to monitor a specific database?](https://www.mindstick.com/mindstickforums/1dc34331-b8f9-470f-8935-beb4727248b5/images/eef4f8c6-a625-4983-8fd9-eafbbda5950f.png)

Here the successfully set up the trace using SQL Server Profiler to monitor `MyCollegeDb` database.

## Stop Trace

If you want to stop the running trace click the **File** menu -> click on **Stop Trace** option.

#### Configure Trace Properties

Switch to the **Events Selection** tab in **Trace Properties** window. This is where you select which events to capture.

\
**Select Events**\
**For the initial trace-** Start with common statements such as `SQL:BatchCompleted`, `SQL:BatchStarting`, `RPC:Completed`, and `RPC:Starting`.

\
**For more detailed monitoring-** You can add events such as **Errors** and **Warnings** > **User Error Messages** or **Performance** > **Performance Statistics.**\

**Filter by Database**\
Click the **Column Filters** button.\
Find and paste the **DatabaseName** into the **columns** listed in the "**Edit Filter**" dialog.\
Set the filter to include only the specific database you want to monitor. For example, you can set **DatabaseName equals <YourDatabaseName>**.

![How to setup a trace using SQL Profiler to monitor a specific database?](https://www.mindstick.com/mindstickforums/1dc34331-b8f9-470f-8935-beb4727248b5/images/ed4d9857-689a-4d1e-829d-6dfd8f1016c1.png)

#### Configure Other Trace Properties

**Data Columns** Select the data columns you want to add to your trace results as data Columns. Common columns include `DatabaseName`, `TextData`, `Duration`, and `SPID`.\
**Events** Make sure you choose the right events based on what you need to watch.\
**File Settings** If you plan to save the trace results, you may want to set up a file system. You can define the file name and location in the Save to file option.

#### Start the Trace

Once the events and filters are configured, click on **Run** to start the trace.\

#### Monitor and Analyze

As the trace runs, it will display real-time information about the activities in the selected database.

You can stop the trace at any time by clicking the Stop button on the toolbar.\

#### Save the Trace

To save trace data for later analysis, go to File > Save As > Trace File or Trace Table depending on how you want to save the trace data.\

#### Additional Tips

**Performance Considerations** When running traces on a production server, pay close attention to the performance impact. Traces can cause significant overhead, so it’s generally best to limit the duration and scope of the trace.\
**Filtering** Use filters intelligently to reduce the amount of data captured and focus on relevant activities.

\
By following these steps, you can effectively monitor specific database operations using SQL Server Profiler.

**Also, Read:** [What is SQL Profiler, and why is it used?](https://www.mindstick.com/forum/160937/what-is-sql-profiler-and-why-is-it-used)


---

Original Source: https://www.mindstick.com/forum/160935/how-to-setup-a-trace-using-sql-profiler-to-monitor-a-specific-database

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
