0

I'm writing a small app that will be used to deploy stored procedure updates/releases across a number of servers.

I need to report back that the update on each server was successful.

At present I'm simply doing the following:

int response =  server.ConnectionContext.ExecuteNonQuery(sql);

This successfully updates the sp, but the response is always a random minus number (-3, -4 etc).

What would be the best way to get a response to report back if each update was successful or not?

JIbber4568
  • 839
  • 4
  • 16
  • 33

2 Answers2

2

What would be the best way to get a response to report back if each update was successful or not

if the query has executed successfully and you haven't caught any exception then it means it is a success. otherwise it failed.

Ehsan
  • 31,833
  • 6
  • 56
  • 65
  • Thanks for that. Assumed as much but didn't know if there was a better way I could actually get a success/fail response. – JIbber4568 Aug 29 '13 at 10:36
0

You can implement Transaction (if your sql command based on multiple table) along with Try-Catch in SQL by using RAISERROR. You get get the error as output variable.

Mohammad Arshad Alam
  • 9,694
  • 6
  • 38
  • 61