[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Capture SQL Messages in text file

Posted on 2013-06-27
6
Medium Priority
?
345 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

650 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