I. INTRODUCTION to SQL Server Profiler
SQL Profiler is a graphical interface and a set of system stored procedures. Its functions are as follows:
Graphical monitoring of SQL Server queries;
Collect query information in the background;
Analysis performance;
Diagnoses problems such as deadlocks;
Debug T-SQL statements;
Simulate replay of SQL Server activities;
You can also use SQL Profiler to capture activities executed on the SQL Server instance. Such an activity is called a Profiler trace.
II. Simple configuration and use of SQL Profiler
I am not talking nonsense much. For more information about SQL Profiler, you can find it on the Internet. Next we will talk about practical operations! (Note: You don't need to mention the local database. You can debug and run it, mainly about the database on the server .)
The SQL Server Express version does not have the SQL Profiler tool. This tool is available in the Enterprise edition and has not been used in other versions. Next let's take a look at where SQL Profiler is located. First open SQL Server Management Sudio and click the menu, Tools> SQL Server Profiler, as shown in the figure:
After you click, the logon page is displayed. After you enter the user name and password, the following page is displayed:
There is a Use the template in row 4. Select Standard. If it is a local database, you only need to access the database and click Run. If there are a lot of people accessing data on the server, the results should be completed. Click the Events Selection tab, as shown in the following figure:
You can see the default options of Standard. You don't need to worry about this. Select the Show all columns check box. Otherwise, the HostName cannot be found. Click Column Filters... to go to the filtering options page:
Find the HostName option in the drop-down list and add your computer name to Like. This will only display the SQL statement sent by this computer.
Then, click "OK" and click "Run" to start tracking. The database access you perform on your computer will be recorded.
Note: on your computer, you access the website on the server. Database access is performed on the server, not on your computer. Only when debugging and running can you access the server from your computer to be tracked.
The tracking result is as follows:
After selecting a record, the executed SQL statement is displayed. As for the stored procedure, we can clearly see the input parameters and copy them for debugging.
If there are too many records, you can select the menu below Edit> Find... to search.
Seeing this, I suddenly felt very simple. Oh, I 've read so many tutorials and talked a lot about it. I couldn't find what I wanted for a long time. The more I get bored!
3. Create your own template for future use
It is inconvenient to change the computer name every time. We can make a template of our own, so we don't need to configure it next time. Let's take a look at how to create your own template:
As shown in the figure, click the menu to open the template page, as shown in the following figure:
Enter your own template name, such as MyProfiler, and then select Base new template on existing one:, which is modified based on an existing template. We still choose Standard, there is also a Use as default template for selected server type, which is set as the default template. After the selected template is selected, the template we added will be selected by default each time we create a trail, it is recommended to check. Click the Events Selection tab and set the HostName. Save it.
Then, click File> New trace... to create a trail. The created template is displayed and selected by default. Then, click Run to continue our work.