Home > SQL Server Tips > Database Management and Administration > SQL Profiler: Features, functions and setup in SQL Server 2005
SQL Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

SQL Profiler: Features, functions and setup in SQL Server 2005


Jeremy Kadlec, Edgewood Solutions
Rating: -4.43- (out of 5)



Trying to find the proverbial needle in the haystack of your SQL Server transactions is no small task. SQL Server Profiler not only helps you find that needle, it gives you details on all the other needles in a single interface. Profiler is truly the best native SQL Server resource to understand micro-level processing occurring on any SQL Server. The data captured by this graphical event-monitoring tool is as valuable to a DBA as the business-related data captured by SQL Server Analysis Services is to analysts.

As you begin to upgrade your servers -- and your skills -- from SQL Server 2000 to 2005, you will be happy to know that there is a low learning curve from a functional perspective and many new features to leverage. An added bonus is you can leverage SQL Server 2005 Profiler against SQL Server 2000 servers. Hence, learning the new interface SQL Server 2005 interface becomes important for your current servers and allows you to take advantage of exciting new opportu...


RELATED CONTENT
Microsoft SQL Server Performance Monitoring and Tuning
SQL sprawl: Why is SQL Server Express installed everywhere?
Top 10 SQL Server tips of 2009
Top 5 SQL Server DBA tasks that are a waste of time
SQL Server Mailbag: Asymmetric encryption, log shipping issues
Using traces in SQL Server Profiler
SQL Server Mailbag: CALs, witnesses and unwanted changes
SQL Server Mailbag: Data restoration and DB property management
Working with IntelliSense in SQL Server 2008 Management Studio
SQL Server Mailbag: Stored procedures, triggers and SSRS reports
Troubleshooting Distributed Transaction Coordinator errors in SQL Server

Microsoft SQL Server 2005
End of life comes for SQL Server 2005 SP2, 2008
SQL Server Service Broker Tutorial and Reference Guide
Tips for tuning SQL Server 2005 to improve reporting performance
SQL Server consolidation: Why it's an optimization technique
Parent-child dimensions in SQL Server 2005 with Analysis Services MDX
Enforcing data integrity in a SQL Server database
Troubleshoot Web service issues in SQL Server 2005 Reporting Services
SSIS error message due to installation problem on SQL Server 2005
Should you upgrade to SQL Server 2005 or SQL Server 2008?
Basics for working with DATETIME and SMALLDATETIME in SQL Server 2005
Microsoft SQL Server 2005 Research

Database Management and Administration
Database encryption in SQL Server 2008: Improvements you finally need
Common oversights with SQL Server security audits
Top 5 SQL Server DBA tasks that are a waste of time
Password cracking tools for SQL Server
Using traces in SQL Server Profiler
Meet compliance requirements with improved database security practices
Hardening the network and OS for SQL Server security
Securing the server and database in SQL Server
How SQL Server 2008 components impact SharePoint implementations
Troubleshooting Distributed Transaction Coordinator errors in SQL Server

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
contiguity  (SearchSQLServer.com)
contiguous  (SearchSQLServer.com)
drilldown  (SearchSQLServer.com)
hashing  (SearchSQLServer.com)
hybrid online analytical processing  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


nities available with SQL Server 2005.

TABLE OF CONTENTS
  [IMAGE] New features in SQL Server 2005 Profiler
  [IMAGE] Tried-and-true features in SQL Server 2005 Profiler
  [IMAGE] How to set up a SQL Server 2005 Profiler session


[IMAGE][IMAGE]  New features in SQL Server 2005 Profiler[IMAGE] Return to Table of Contents


Although the interface for SQL Server 2005 Profiler was not changed as dramatically as the interfaces for Enterprise Manager and Analysis Manager, which were merged into Management Studio, the subtle features are beneficial and ease some historical performance-tuning challenges. These features include:

  • A single interface with all options to configure the Profiler session:
    • Trace Events, Columns, Filtering, etc.

  • New profiling events:
    • Service Broker, CLR, Full Text, etc.

  • The ability to profile SQL Server 2005 Analysis Services, which has been a black box with earlier versions of SQL Server.
    • This topic will be covered in a future tip.

  • Integration between SQL Server Profiler data and Performance Monitor data into a single interface to correlate the macro- and micro-level data
    • This topic will also be covered in a future tip.


[IMAGE][IMAGE]  Tried-and-true features in SQL Server 2005 Profiler[IMAGE] Return to Table of Contents


Many SQL Server 2000 Profiler features are back by popular demand -- keeping the learning curve to a minimum -- and new features are available to quickly leverage the technology.

  • Authentication: Remains the first interface when the application is started, but now has options for connecting to Analysis Server.
  • Data capture: Enables you to write to a table, record on the screen or save to a text file.
  • Graphical user interface and T-SQL commands: Enable you to run Profiler interactively on your desktop or on a predefined schedule with SQL Server Agent.
  • T-SQL interface: Allows you to schedule Profiler to execute on a regular basis and write the data for future analysis.
    • sp_trace_create
    • sp_trace_generateevent
    • sp_trace_setevent
    • sp_trace_setfilter
    • sp_trace_setstatus


[IMAGE][IMAGE]  How to set up a SQL Server 2005 Profiler session[IMAGE] Return to Table of Contents


Although on the surface SQL Server 2005 Profiler has not changed dramatically, you may still need help setting up a Profiler session. Here I'll outline several steps to get you up and running. The final step includes sample T-SQL queries to analyze the SQL Server Profiler results.



SQL Server 2005 Profiler session setup
ID Directions Screen Shot
1 Start SQL Server 2005 Profiler via the GUI interface by navigating to Start | All Programs | Microsoft SQL Server 2005 | Performance Tools | SQL Server Profiler.

[IMAGE]


2 Start a new Trace session by selecting the 'File' menu and the 'New Trace' option. Once the 'Connect to Server' interface loads, select the 'Type' as either 'Database Engine' or 'Analysis Services'. For this tip we will use the 'Database Engine' option. Then select the 'Server Name' followed by the 'Authentication' type. Finally, press the 'Connect' button to start the configuration.

[IMAGE]


3 Configure SQL Server Profiler Trace Properties – General Tab:

  • Trace Name: Specify a meaningful name for the session
  • Use the template: A total of eight templates are available with predefined events selected
    • For this tip we will use the 'Standard (default)' template
  • Save to file or Save to table: To retain a copy of the data save the results to either a database table or Windows file.
    • For this tip we will save the results to the dbo.TraceResults table in my user defined database.
    [IMAGE]
    4 Configure SQL Server Profiler Trace Properties – Events Selection Tab:
  • Review the specific events and select the needed check boxes to capture the desired data.
  • Show All Events: Select this check box to see all events that Profiler will be able to capture.
  • Show All Columns: Select this check box to see all columns that Profiler will be able to capture.
  • [IMAGE]


    5 Additional Configuration – Column Filters

  • Specify filters based on the columns that are selected for the session to limit the data.
  • [IMAGE]


    6 Additional Configuration – Organize Columns

  • Specify the column order as well grouping settings for the final data.
  • [IMAGE]


    7 To start the session, press the 'Run' button on the Trace Properties interface.

    [IMAGE]


    8 Review the results that are captured in the Profiler interface.

    [IMAGE]


    9 Sample T-SQL queries to analyze the SQL Server Profiler results.

    -- Total transactions per database in the last one hour
    SELECT COUNT(*) AS 'Total Records',
    DB_NAME(DatabaseID) AS 'Database Name'
    FROM dbo.TraceResults (NOLOCK)
    WHERE StartTime BETWEEN DATEADD(Hour, -1,
    GETDATE()) AND GETDATE()

    GROUP BY DatabaseID
    ORDER BY DatabaseID
    GO

    -- High CPU usage in the last one hour
    USE AdventureWorks
    GO
    SELECT *
    FROM dbo.TraceResults (NOLOCK)
    WHERE CPU > 5000
    AND StartTime BETWEEN DATEADD(Hour, -1,
    GETDATE()) AND GETDATE()
    GO

    -- Long duration in the last one hour
    USE AdventureWorks
    GO
    SELECT *
    FROM dbo.TraceResults (NOLOCK)
    WHERE Duration > 10000000
    AND StartTime BETWEEN DATEADD(Hour, -1,
    GETDATE()) AND GETDATE()
    GO

    Conclusion

    SQL Server 2005 Profiler remains the primary tool for capturing performance metrics at a transaction level in SQL Server. Although all systems experience performance problems, hopefully the problem is not a needle in a haystack and you will be able to easily find and correct your performance issues. Good luck!

    About the author: Jeremy Kadlec is the Principal Database Engineer at Edgewood Solutions, a technology services company delivering professional services and product solutions for Microsoft SQL Server. He has authored numerous articles and delivers frequent presentations at regional SQL Server users groups and nationally at SQL PASS. Kadlec is the SearchSQLServer.com Performance Tuning expert. Ask him a question here.


    More information from SearchSQLServer.com

  • Checklist: SQL Server performance-tuning checklist
  • Webcast: SQL Server performance tuning myths webcast
  • Step-by-Step Guide: Hunt down SQL Server performance problems


  • Rate this Tip
    To rate tips, you must be a member of SearchSQLServer.com.
    Register now to start rating these tips. Log in if you are already a member.




    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



    SQL Server Development - .NET, C#, T-SQL, Visual Basic
    HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Site Map




    All Rights Reserved, Copyright 2005 - 2010, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts