Write "Messages" window to a log file?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hermes

    Write "Messages" window to a log file?

    Is there a way to write the information that appears in the "Messages"
    window in SQL Server Management Studio to an external log file? I'd
    like to keep a record of these logs as I run each script once a month
    and it would be useful to compare run times for each step. We have
    several places where we insert variations of the following code along
    the way which gives us a snapshot of how long a particular step took:

    SET @Msg = '[STEP 1] - Starting - __GlobalDeleteN onClusteredInde xes
    '+
    CONVERT(varchar (20),GETDATE(), 101)+' '+
    CONVERT(varchar (20),GETDATE(), 108)

    RAISERROR(@Msg, 0, 1) WITH NOWAIT

    Any help is appreciated.
  • Erland Sommarskog

    #2
    Re: Write "Messages& quot; window to a log file?

    Hermes (manningfan@gma il.com) writes:
    Is there a way to write the information that appears in the "Messages"
    window in SQL Server Management Studio to an external log file? I'd
    like to keep a record of these logs as I run each script once a month
    and it would be useful to compare run times for each step. We have
    several places where we insert variations of the following code along
    the way which gives us a snapshot of how long a particular step took:
    >
    SET @Msg = '[STEP 1] - Starting - __GlobalDeleteN onClusteredInde xes
    '+
    CONVERT(varchar (20),GETDATE(), 101)+' '+
    CONVERT(varchar (20),GETDATE(), 108)
    >
    RAISERROR(@Msg, 0, 1) WITH NOWAIT
    >
    Any help is appreciated.
    Try View->Results->To File from the menu.


    --
    Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

    Links for SQL Server Books Online:
    SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
    SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
    SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

    Comment

    Working...