Sreejith! - Wednesday, May 24, 2017 3:04 PM
Not all columns are available for all events and object name isn't available for SQL:StmtStarting.
You would need to filter on the text data for the object names and for logical operator, you would need to use OR on the second table if you wanted Table1 or Table2. So for your filters try something along the lines of this if you want select statements for Table1 or Table2 in YourDatabase: exec sp_trace_setfilter @TraceID, 1, 0, 6, N'%SELECT%'
exec sp_trace_setfilter @TraceID, 1, 0, 6, N'%Table1%'
exec sp_trace_setfilter @TraceID, 1, 1, 6, N'%Table2%'
exec sp_trace_setfilter @TraceID, 35, 0, 6, N'%YourDatabase%'
For the filters, you can find more information in this topic:
sp_trace_setfilter (Transact-SQL)
And then check the event class to see which columns are available. So in your case, refer to this article:
SQL:StmtStarting Event Class
The example you are using is using the event above and then filtering the column text data using like '%SELECT%'
Sometimes it's easier to just open up profiler and setup what the example has and then setup your own filters and export the trace definition. If you wanted to try that, just create the trace with SQL:StmtStarting and add the filters you want. You have to start a trace to export the definition so then start it and stop it right away. Then go to the menu, to File, to Export and Export Trace Definition to save it off as a sql file.
Sue