By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,805 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,805 IT Pros & Developers. It's quick & easy.

Capturing the plain-text output of a stored procedure

P: n/a
I'm using ADO.NET to call a stored procedure that runs the "BACKUP" command
on selected databases. Is there any way I can capture the text output of the
stored proc and return it to ADO.NET for displaying in my application?

When I run the stored procedure from SQL Query Analyzer, I get an output (in
the messages tab) like:

Processed 1496 pages for database 'OldBO', file 'TB_BackOffice_Data' on file
1.
Processed 1 pages for database 'OldBO', file 'TB_BackOffice_Log' on file 1.
BACKUP DATABASE successfully processed 1497 pages in 1.909 seconds (6.420
MB/sec).
Processed 120 pages for database 'Profile', file 'Profile_Data' on file 1.
Processed 1 pages for database 'Profile', file 'Profile_Log' on file 1.
BACKUP DATABASE successfully processed 121 pages in 0.293 seconds (3.358
MB/sec).
Processed 104 pages for database 'Quotes', file 'Quotes_Data' on file 1.
Processed 1 pages for database 'Quotes', file 'Quotes_Log' on file 1.

etc...

This is the information I'd like to capture (plus any other messages that my
be created from "PRINT" statements within the sp).

Thanks,
Dimitris
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Informational messages can be retrieved by handling the your connection
object InfoMessage event. This includes PRINT and RAISERROR statements
(severity < 11).

--
Hope this helps.

Dan Guzman
SQL Server MVP

-----------------------
SQL FAQ links (courtesy Neil Pike):

http://www.ntfaq.com/Articles/Index....partmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------

"Dimitris" <sp**@hotmail.com> wrote in message
news:3f*********************@lovejoy.zen.co.uk...
I'm using ADO.NET to call a stored procedure that runs the "BACKUP" command on selected databases. Is there any way I can capture the text output of the stored proc and return it to ADO.NET for displaying in my application?

When I run the stored procedure from SQL Query Analyzer, I get an output (in the messages tab) like:

Processed 1496 pages for database 'OldBO', file 'TB_BackOffice_Data' on file 1.
Processed 1 pages for database 'OldBO', file 'TB_BackOffice_Log' on file 1. BACKUP DATABASE successfully processed 1497 pages in 1.909 seconds (6.420 MB/sec).
Processed 120 pages for database 'Profile', file 'Profile_Data' on file 1. Processed 1 pages for database 'Profile', file 'Profile_Log' on file 1. BACKUP DATABASE successfully processed 121 pages in 0.293 seconds (3.358 MB/sec).
Processed 104 pages for database 'Quotes', file 'Quotes_Data' on file 1. Processed 1 pages for database 'Quotes', file 'Quotes_Log' on file 1.

etc...

This is the information I'd like to capture (plus any other messages that my be created from "PRINT" statements within the sp).

Thanks,
Dimitris

Jul 19 '05 #2

P: n/a
Dimitris,

What I think you want to do is get the connection for the server. Once
you have the instance of the SqlConnection, you can hook up to the
InfoMessage event, which ^should^ be fired when there is message information
sent with the resultset.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Dimitris" <sp**@hotmail.com> wrote in message
news:3f*********************@lovejoy.zen.co.uk...
I'm using ADO.NET to call a stored procedure that runs the "BACKUP" command on selected databases. Is there any way I can capture the text output of the stored proc and return it to ADO.NET for displaying in my application?

When I run the stored procedure from SQL Query Analyzer, I get an output (in the messages tab) like:

Processed 1496 pages for database 'OldBO', file 'TB_BackOffice_Data' on file 1.
Processed 1 pages for database 'OldBO', file 'TB_BackOffice_Log' on file 1. BACKUP DATABASE successfully processed 1497 pages in 1.909 seconds (6.420
MB/sec).
Processed 120 pages for database 'Profile', file 'Profile_Data' on file 1.
Processed 1 pages for database 'Profile', file 'Profile_Log' on file 1.
BACKUP DATABASE successfully processed 121 pages in 0.293 seconds (3.358
MB/sec).
Processed 104 pages for database 'Quotes', file 'Quotes_Data' on file 1.
Processed 1 pages for database 'Quotes', file 'Quotes_Log' on file 1.

etc...

This is the information I'd like to capture (plus any other messages that my be created from "PRINT" statements within the sp).

Thanks,
Dimitris

Jul 19 '05 #3

P: n/a
Also, if you could not set the reply address to valid address that is
not yours (such as) sp**@hotmail.com, I would appreciate it.

--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Dimitris" <sp**@hotmail.com> wrote in message
news:3f*********************@lovejoy.zen.co.uk...
I'm using ADO.NET to call a stored procedure that runs the "BACKUP" command on selected databases. Is there any way I can capture the text output of the stored proc and return it to ADO.NET for displaying in my application?

When I run the stored procedure from SQL Query Analyzer, I get an output (in the messages tab) like:

Processed 1496 pages for database 'OldBO', file 'TB_BackOffice_Data' on file 1.
Processed 1 pages for database 'OldBO', file 'TB_BackOffice_Log' on file 1. BACKUP DATABASE successfully processed 1497 pages in 1.909 seconds (6.420
MB/sec).
Processed 120 pages for database 'Profile', file 'Profile_Data' on file 1.
Processed 1 pages for database 'Profile', file 'Profile_Log' on file 1.
BACKUP DATABASE successfully processed 121 pages in 0.293 seconds (3.358
MB/sec).
Processed 104 pages for database 'Quotes', file 'Quotes_Data' on file 1.
Processed 1 pages for database 'Quotes', file 'Quotes_Log' on file 1.

etc...

This is the information I'd like to capture (plus any other messages that my be created from "PRINT" statements within the sp).

Thanks,
Dimitris

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.