Solved

Capture SQL Messages in text file

Posted on 2013-06-27
6
325 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
  • 4
6 Comments
 
LVL 16

Expert Comment

by:Surendra Nath
Comment Utility
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
Comment Utility
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
Comment Utility
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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 

Author Comment

by:cottage125
Comment Utility
No one has replied yet so closing this question.
0
 

Author Comment

by:cottage125
Comment Utility
No one has replied yet so closing this question.
0
 

Author Closing Comment

by:cottage125
Comment Utility
No one has replied yet so closing this question.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now