2

I have a long running stored procedure, executed in a thread (via TADOStoredProc) to ensure that the application remains responsive.

There are a number of RAISERROR() WITH NOWAIT statements in the stored procedure so I can monitor progress while running it in SSMS.

Is there any way that the application can get these messages so that I can give the users some indication of progress?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Keith Miller
  • 1,718
  • 1
  • 13
  • 22
  • 3
    Why not insert the logging in a table that a separate process can read / poll? – Stu Jun 21 '23 at 08:25
  • Or create an extended event with sp_statement_started and completed. – Peter Jun 21 '23 at 08:47
  • 3
    Try handling the [Data.Win.ADODB.TADOConnection.OnInfoMessage](https://docwiki.embarcadero.com/Libraries/Alexandria/en/Data.Win.ADODB.TADOConnection.OnInfoMessage) event. – Dan Guzman Jun 21 '23 at 10:34
  • Thanks @DanGuzman, that worked. Please add that as an answer so I can accept it – Keith Miller Jun 21 '23 at 13:38

1 Answers1

2

Messages (e.g. PRINT and RAISERROR) may be captured by handling the ADODB.Connection.InfoMessage event in ADO classic. This is exposed by the Data.Win.ADODB.TADOConnection.OnInfoMessage event.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Dan Guzman
  • 43,250
  • 3
  • 46
  • 71