Is it possible to use SQL Profiler to observe queries being requested of a LocalDB instance?
相关问题
- sql execution latency when assign to a variable
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
- SQL to Parse a Key-Value String
相关文章
- Entity Framework 4.3.1 failing to create (/open) a
- Profiling Django with PyCharm
- Code for inserting data into SQL Server database u
- Delete Every Alternate Row in SQL
- Linux based PHP install connecting to MsSQL Server
- SQL Azure Reset autoincrement
- How do we alias a Sql Server instance name used in
- Is recursion good in SQL Server?
It as simple as setting the server to (LocalDB)\v11.0
http://expressprofiler.codeplex.com/discussions/456518
From http://expressprofiler.codeplex.com/
This is what I used on SQL Server Express 2012 (note: not "LocalDB* - I have never used LocalDB so maybe that is different to a "regular" SQL Server Express).
Step 1: Setup the trace
This is basically the "hard work". You first need to find out where the default log directory of SQL Server is. You need this directory name to specfiy the trace file.
Then create a trace by doing something like this:
Now for every event that should be traced, you need to call
sp_trace_setevent
multiple times to define which column for that event should be returned:For a full list of events and columns, see: http://msdn.microsoft.com/en-US/library/ms186265%28v=sql.90%29.aspx
All of the above calls must be done for each and every event you want to trace!
I find the events
12 = SQL:BatchCompleted
,42 = SP:Starting
,43 = SP:Completed
,45 = SP:StmtCompleted
,50 = SQL Transaction
the most interesting ones.Optionally you can setup a filter, I usually filter out system events and only show events for a specific database:
Once the trace is setup, it must be activated:
(Note the above must be run as a single batch, because of the variable usage).
To see how the trace was defined, you can use the following statement:
Now run your application or whatever issues statements to the database that you want to trace.
Step 2: Retrieve trace information
For this you need to know the full path to the actual trace file (from Step 1). Note that for
fn_trace_gettable
you need to specify the file including the file extension.Adjust the above to return the information you are interested in.
Once you have the information you need, you have to turn off the trace:
Step 3: disable the trace
For this you need to know the Trace-ID (e.g. by running the "info statement from Step 1). The with this ID, you need to first stop the trace, then you can delete it:
Microsoft SQL Server 2012 Express LocalDB is an execution mode of SQL Server Express targeted to program developers.
Sql Profiler is not provided with SQL Server Express.
Thus, you can't use Sql profiler for your LocalDB.
However,you can go through alternative ways.
How to use SQL Profiler with SQL Server Express Edition
You can use SQL Profiler just as you do with all other SQL editions as long as you know the proper server name. You can find the server name using the SqlLocalDb utility.
To find it, use
sqllocaldb info YourInstanceName
to find theInstance Pipe Name
. It has the formnp:\\.\pipe\LOCALDB#12345\tsql\query
Use this as the server name to connect to the server and start profiling