I am running a running a SQL Server Profiler, a graphical tool to track SQL Server Activities, I am done with my analysis but prior to close SQL Server Profiler Tool, Can I save the result in SQL Server or in Excel ?
Can I export SQL Server Profile / Trace file data to SQL Server as a table data ?
How can I download SQL Server Profiler / Trace data in SQL Server Table ?
YES, we can export SQL Server Trace / Profiler data into a SQL Server Table. There are various ways to export SQL Server Profiler / Trace data to a SQL Server table.
Method 1 – Graphical
By default the SQL Server profiler / trace data will be displayed in SQL Server Profiler tool, as shown picture below.
To export this data in SQL Server, select File Menu >> SAVE AS and finally opt Trace Table as shown below.
Once you select Trace Table, SQL Server Authentication window will come and ask your on which Server / Database Name and table, in which you want to export the database, this will automatically create a table, if that doesn’t;t exists.
Method 2 – Using TSQL Statement
It profiler / trace data is already saved in a .trc file, then we can read the trace file using function name ::fn_trace_gettable()
TSQL query to open a trace file in SQL Server Management Studio (SSMS)
SELECT * FROM ::fn_trace_gettable ('<<SQL Server Trace File Name>>', default)
this will display the data in result pane, so now if we want to save this in a SQL Server table then we can easily add a INTO clause in this statement and save data in SQL table as below.
SELECT * into table_name_in_which_we_want_save_data FROM ::fn_trace_gettable ('<<SQL Server Trace File Name>>', default)
