Solved

Capture SQL Messages in text file

Posted on 2013-06-27
6
337 Views
Last Modified: 2013-10-07
When I run following command in SSMS query window,
exec test.dbo.sp_do_backups 'FULL', 'USER','C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\BACKUP\'  This SP takes backup of multiple dbs on server and it runs longer and generates following messages in message Pane as shown below.

DateTime: 2013-06-27 16:42:32
Server: TEST
Version: 9.00.5057.00
Edition: Enterprise Edition (64-bit)
Procedure: [test].[dbo].[p_dba_do_backups]
Parameters: @database_name = NULL, @backup_location = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\BACKUP\', @backup_type = 'FULL'
23 percent processed.
33 percent processed.
63 percent processed.
99 percent processed.
Processed 312 pages for database 'test', file 'test_Data' on file 1.
100 percent processed.
Processed 1 pages for database 'test', file 'test_Log' on file 1.
BACKUP DATABASE successfully processed 313 pages in 1.614 seconds (1.588 MB/sec).


However when I run the same SP  inside execute sql task in maintenance plan, I am not able to see above test. I need to store above data in some text file so that I can check that file if any error message is generated. Tell me the most simple way to do it using only SQL SERVER.
0
Comment
Question by:cottage125
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39283172
the simplest way in SQL Server is to change the above stored procedure, and put a try..catch block around it

and at the end of try block return 0 and at the end of catch block return 1.

Now, you try to handle the return value in your script task, ensure that it is 0, or else treat it as failure.
0
 
LVL 16

Expert Comment

by:EvilPostIt
ID: 39283646
If you execute this stored procedure from a SQL Server agent task, with the step that you would configure on the advanced tab there is an option called "Output file". This will allow you to save your output to file. Assuming you want to schedule it...
0
 

Accepted Solution

by:
cottage125 earned 0 total points
ID: 39284599
TO- Neo_jarvis Thanks but I am using execute SQL task from inside of maintenance plan and I dont see in the properties any return value related expression that I can set there. Can u explain me in more detail??
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:cottage125
ID: 39539741
No one has replied yet so closing this question.
0
 

Author Comment

by:cottage125
ID: 39539743
No one has replied yet so closing this question.
0
 

Author Closing Comment

by:cottage125
ID: 39551646
No one has replied yet so closing this question.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question