Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2008

    Unanswered: Stored Procedure message to user.


    Is it possible to send a user a message in a stored procedure in the same way that you can send an error message?

    I can use the following to send errors to the user
    IF len(@Batchref)=0
    SELECT @ErrorStr = 'Please Enter a Batch Ref first'
    Return -1

    But at the end of the SP I want to send a message saying "You have created Batch XYZ".

    Any Ideas?


  2. #2
    Join Date
    Nov 2004
    on the wrong server
    Provided Answers: 6
    SELECT 'You have created Batch XYZ'
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Feb 2009
    You can use RAISERROR with a severity less than 16 and it will show up like a print.

    I use RAISERROR a lot for scripts as you can use the WITH NOWAIT. Great for debug.

    RAISERROR('You have created Batch XYZ', 10, 10) WITH NOWAIT

    Using SELECT will return the message to the calling program -- don't know if that is what you want.

    You could also use the RETURN command to return an INT indicating success

    That way you can interrogate the return result in your app or whatever to see if it was successfull.

    Your exec call would become

    EXEC @returnVal = yourStoredProc

  4. #4
    Join Date
    Dec 2008
    create a @errormessage varchar(32) = null output
    output variable in ur spparameters and return it

    select @errormessage = 'You have created Batch XYZ'

    select @errormessage

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts