Capturing results messages

  • I'm executing several discrete queries in a single batch against SQL Server. For example:

    update tableX set colA = 'freedom';

    select lastName from customers;

    insert into tableY (a,b,c) values (x,y,z);

    Now, I want to capture the result in a DataSet (from select statement) which is easy enough to do...but how do I also capture the "meta" response from that command similar to the way Query Analyzer/SQL Mgt Studio does when it displays the "Messages" tab and diplays something similar to:

    (1 Row affected)

    (2 Rows Updated)

  • You didn't say anything about technology you use to run these commands, but for .NET, you should look at the InfoMessage event fired by SqlConnection:

    http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.infomessage.aspx

    HTH

    Piotr

    ...and your only reply is slàinte mhath

  • I use them on SSIS packages.

  • Look at @@RowCount

    That should help

    -Roy

  • And do you mind if I ask what do you need these messages for?

    ...and your only reply is slàinte mhath

  • I'm a bit skeptical that you'll find a way to read the "meta" responses as QA or SSMS does via SSIS. This type of stuff is usually best represented in SSIS as seperate tasks; one for each data manipulation. Putting this logic in a stored procedure and manually capturing @@RowCount after each DML statement may be your best bet.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply