Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL server profiler not showing LINQ To Sql queries

I am trying to view SQL generated by Linq to SQL in the SQL Server Profiler (2005).

I can see the sql sent to the server from anything except for linq to sql.

I'm betting that I need to change event selections for the trace, but not sure what else to select.

I am currently only selecting this: SQL:StmtCompleted - TextData & SPID

I don't want to use data context logging nor the SQL Debug Visualizer. I need to use the profiler.

Why can I not see the LINQ to SQL queries?

Thanks.

EDIT

I added SQL:BatchCompleted and that hasn't helped.

EDIT 2

I added the event RPC:Completed which is found under the Stored Procedures category in event selection. This worked!

like image 738
Ronnie Overby Avatar asked Apr 08 '09 12:04

Ronnie Overby


People also ask

How can I see the LINQ query in SQL Profiler?

Now, let's run the Application and run the trace in SQL Server Profiler. Click on Get Data button, the data will be populated on the page. Go to SQL Server Profiler and stop the trace, where you will see T-SQL statement of our stored procedure, as shown below. Notice that GetEmployees stored procedure is executed.

How LINQ queries converted into SQL queries?

LINQ to SQL translates the queries you write into equivalent SQL queries and sends them to the server for processing. More specifically, your application uses the LINQ to SQL API to request query execution. The LINQ to SQL provider then transforms the query into SQL text and delegates execution to the ADO provider.

Is SQL Server Profiler deprecated?

SQL Server Profiler is an interface to create and manage traces and analyze and replay trace results. Events are saved in a trace file that can later be analyzed or used to replay a specific series of steps when diagnosing a problem. SQL Trace and SQL Server Profiler are deprecated.


2 Answers

You need RPC call - the queries are executed as exec_sql.

like image 156
cjk Avatar answered Oct 09 '22 12:10

cjk


Are you including enough of the options in the SQL Profiler to see the BatchCompleted events, too?

Marc

like image 39
marc_s Avatar answered Oct 09 '22 13:10

marc_s