locked
running SQL profiler using T-SQL commands RRS feed

  • Question

  • HI,

    Can anybody tell me how we can run SQL profiler through T-SQL command?

    Thursday, October 13, 2011 5:13 AM

Answers

  • Thats great!!!

    Is it only the option with SQL Server 2008 or with other versions too? How to pass the filters and event selection?

     

    Thanks!

    Sachin


    http://msdn.microsoft.com/en-us/library/ms162808(v=SQL.100).aspx
    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker
    --------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------------------------------------------------------------------
    My Blog | Team Blog | @Twitter
    • Marked as answer by SirIndian Thursday, October 13, 2011 10:57 AM
    Thursday, October 13, 2011 6:22 AM

All replies

  • thats called server side trace.
    http://technet.microsoft.com/en-us/library/cc293613.aspx
    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker
    --------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------------------------------------------------------------------
    My Blog | Team Blog | @Twitter
    Thursday, October 13, 2011 5:23 AM
  • Thanks a lot. Also can we open SQL profiler's graphical interface using T-SQL commands?
    Thursday, October 13, 2011 5:27 AM
  • can we open SQL profiler's graphical interface using T-SQL commands?

    No. Why do you want to do that?
    SQL Profiler is an executable which can be opened by start > run > profiler90 (or profiler in SQL 20008 onwards)
    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker
    --------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------------------------------------------------------------------
    My Blog | Team Blog | @Twitter
    Thursday, October 13, 2011 5:31 AM
  • I have application which takes a pre-formatted login crdentials create Batch file and opens the SSMS. No need to manually login to the database. Now what I want to try is, when I click LOGIN button of my application with login information pasted in my application, it should open SQL profiler using that credentials. Is that possible?

    Thursday, October 13, 2011 5:36 AM
  • i hope you are passing parameters to ssms.exe. Same way you can pass parameter to Profiler.exe


    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker
    --------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------------------------------------------------------------------
    My Blog | Team Blog | @Twitter
    • Proposed as answer by Naomi N Friday, October 14, 2011 7:10 PM
    Thursday, October 13, 2011 5:53 AM
  • Thats great!!!

    Is it only the option with SQL Server 2008 or with other versions too? How to pass the filters and event selection?

     

    Thanks!

    Sachin

    Thursday, October 13, 2011 6:18 AM
  • Thats great!!!

    Is it only the option with SQL Server 2008 or with other versions too? How to pass the filters and event selection?

     

    Thanks!

    Sachin


    http://msdn.microsoft.com/en-us/library/ms162808(v=SQL.100).aspx
    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker
    --------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------------------------------------------------------------------
    My Blog | Team Blog | @Twitter
    • Marked as answer by SirIndian Thursday, October 13, 2011 10:57 AM
    Thursday, October 13, 2011 6:22 AM
  • Hi Balmukund,

    I am facing problem when trying to open the SQL 2000 profiler using the command line. My command line is:

    profiler /S localhost /D Demo60 /U demo /P demo /T "Sachin_SQLBatchCompleted".

    It opens the 2000 profiler but later is shows "SQL server does not exists or access denied". It works when I open the profiler and enter the login credentials manually

    Do you have any idea why this may be happening.

     

    Thursday, October 13, 2011 11:03 AM
  • It works for me.. as per message, server name is incorrect. Can you connect to server and share output of Select @@ServerName and Select @@version
    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker
    --------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------------------------------------------------------------------
    My Blog | Team Blog | @Twitter
    Thursday, October 13, 2011 11:11 AM
  • Still not working....here is the screenshot

    Thursday, October 13, 2011 11:23 AM
  • Any solution to this?
    Monday, October 17, 2011 2:16 AM
  • The command Balmukund posted needs to be run from the command-line, not SSMS.  SSMS is intended to run T-SQL statements.

    It is possible to shell out to other applications like Profiler but why would you want to do that?  You can launch Profiler directly from SSMS using the Tools menu.

     


    Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/
    Monday, October 17, 2011 2:22 AM
  • I have application which takes a pre-formatted login crdentials create Batch file and opens the SSMS. No need to manually login to the database. Now what I want to try is, when I click LOGIN button of my application with login information pasted in my application, it should open SQL profiler using that credentials.

    Now It works fine with 2k5 and 2k8 but for 2k its getting hanged when  I run the "profiler" command through batch file. Error I am getting is "SQL Server does not exists or Access  Denied". Any Idea?

    Monday, October 17, 2011 4:10 AM
  • Perhaps SQL 2000 Profiler doesn't accept the same command-line options as the newer versions.  Unfortunately, I don't have a SQL 2000 box to test this on.  If you type "profiler /?", do you get the same options listed?

     

     


    Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/
    Monday, October 17, 2011 12:16 PM
  • I just confirmed in SQL 2000 that the error posted by Sachin would come if server name is incorrect.
    Interestingly, server name which i see in screenshot (title bar) and different from @@servername


    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker
    --------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------------------------------------------------------------------
    My Blog | Team Blog | @Twitter
    Monday, October 17, 2011 12:27 PM
  • Perhaps SQL 2000 Profiler doesn't accept the same command-line options as the newer versions.  Unfortunately, I don't have a SQL 2000 box to test this on.  If you type "profiler /?", do you get the same options listed?

     

     


    Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/


    It does. Here is profiler /? output:


    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker
    --------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------------------------------------------------------------------
    My Blog | Team Blog | @Twitter
    • Proposed as answer by Naomi N Monday, October 17, 2011 1:10 PM
    Monday, October 17, 2011 12:27 PM