When it comes to tracking SQL statements, some people may ask about this function, and some may think of using the audit function. To track SQL statements and enable the audit function, it will become a waste or
When it comes to tracking SQL statements, some people may ask about this function, and some may think of using the audit function. To track SQL statements and enable the audit function, it will become a waste or
When it comes to tracking SQL statements, some people may ask about this function. Some may think of using the audit function. To track SQL statements and enable the audit function, it will become a waste, maybe the user just wants to track all the SQL statements of a certain connection?
Take a simple example:
1> set tracefile "d:/abc.txt"
2> go
1> set show_sqltext on
2> set statistics io on
3> go
1> select * from t123
2> go
Id col2
-------------------------------------------
Open d: \ abc.txt, And the content is as follows:
========================================================== ==========================================================
Application Tracing report for spid 26 from application "isql"
Run by login "sa" on host "SEAN-E6400"
Tracing started on 05:15:34. 48
========================================================== ==========================================================
05:15:50. 70
No useful sqltext available.
Total writes for this command: 0
End of Batch 4
05:15:55. 28
SQL Text: select * from t123
Table: t123 scan count 1, logical reads: (regular = 1 APL = 0 total = 1), physical reads: (regular = 0 APL = 0 total = 0 ), APT IOs used = 0
Total writes for this command: 0
End of Batch 5
In this case, it is quite convenient. The index lists the on/off option on the top and common ones here:
1. set show_sqltext
2. set showplan
3. set statistics io
4. set statistics time
5. set statistics plancost
Note:
Set tracefile" " This is the matching of the trail All SQL statements connected
Set tracefile" "Only trace all SQL statements currently connected.
Set tracefile on/off (enable or disable)
Of course, dbcc traceon (100) will also output some tracing results on the server side.