January 16, 2009 at 3:48 pm
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)
January 16, 2009 at 6:03 pm
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
January 19, 2009 at 7:22 am
I use them on SSIS packages.
January 19, 2009 at 7:38 am
Look at @@RowCount
That should help
-Roy
January 19, 2009 at 12:14 pm
And do you mind if I ask what do you need these messages for?
...and your only reply is slàinte mhath
January 19, 2009 at 9:11 pm
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.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply