<p>I'm executing several discrete queries in a single batch against SQL Server. For example:</p>

<pre>
update tableX set colA = 'freedom';

select lastName from customers;

insert into tableY (a,b,c) values (x,y,z);
</pre>

<p>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:</p>

<pre>
(1 Row affected)
(2 Rows Updated)
</pre>

My suggestion would be to use the @@rowcount variable for this.  Usually, when I'm doing these kind of commands, if I want to trap both the potential error and the rows affected, I do
```
```
declare @rowsAffected int, @error int

select * from sometable
     select @rowsAffected = @@rowcount, @error = @@error

if @@error <> 0 goto errorCleanup
```
```