472,114 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,114 software developers and data experts.

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 - __GlobalDeleteNonClusteredIndexes
'+
CONVERT(varchar(20),GETDATE(),101)+' '+
CONVERT(varchar(20),GETDATE(),108)

RAISERROR(@Msg, 0, 1) WITH NOWAIT

Any help is appreciated.
Aug 7 '08 #1
1 5116
Hermes (ma********@gmail.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 - __GlobalDeleteNonClusteredIndexes
'+
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, es****@sommarskog.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

Aug 7 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mark Shroyer | last post: by
10 posts views Thread by Andrew Ducker | last post: by
2 posts views Thread by Dansk | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.