Click here to Skip to main content
15,887,683 members
Articles / Database Development / SQL Server
Tip/Trick

How to trace SQL Server Express without using SQL Profiler

Rate me:
Please Sign up or sign in to vote.
5.00/5 (7 votes)
20 Feb 2012CPOL 99.3K   16   4
SQL Profiler is not included with SQL Express, this tip will help if you need to track client activity.
To trace T_SQL queries submitted to SQL Express:

Start the SQL Express Service from the command prompt (run command prompt as Administrator if you are working on Windows 7 or Vista) with the following Trace Flag:


net start MSSQL$SQLEXPRESS /T4032

This now causes all queries issued by all conections to be traced. In order to have the trace output sent to the error log, enable trace flag 3605.


Execute the following in SQL Server Management Studio:


dbcc traceon(3605, -1) -- The -1 makes this global, i.e. applies to all sessions / connections

The logs can be found in C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Log\ERRORLOG.


The logs will now contain the queries that were issued by the clients.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionIdealSqlTracer is a Simple, Free, Open Source Alternative to SQL Profiler Pin
Wade Harvey9-Jul-17 9:34
Wade Harvey9-Jul-17 9:34 
IdealSqlTracer is a simple, free, open source alternative to SQL Profiler. The advantage of IdealSqlTracer is that it takes all of the sql generated behind the scenes in a desktop application or web page, and it formats it to make it easily readable. IdealSqlTracer takes this beautifully formatted sql, and puts it into notepad. This allows you to easily cut-n-paste the sql in notepad, and run it directly in Sql Server Management Studio (SSMS). The advantage of doing this is that it makes it possible for you to see exactly what is going on in your application or website. IdealSqlTracer utilizes sp_trace_create, sp_trace_filter, sp_trace_setstatus sql procs to create these custom traces for you.
QuestionThe log file location varies in different machine. Pin
leiyangge11-Mar-14 20:19
leiyangge11-Mar-14 20:19 
QuestionSQL Server Profiler 2012 Free Pin
Ivan Dario Ospina13-Jun-13 7:54
Ivan Dario Ospina13-Jun-13 7:54 
BugRe: SQL Server Profiler 2012 Free Pin
Member 871442115-Apr-15 8:15
Member 871442115-Apr-15 8:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.