My fairly simple stored procedure does this on line 44:

IF @a = @b
    RAISERROR('blah blah blah', 11, 1)
    RETURN

The stored procedure is invoked client-side using the .NET Framework System.Data.SqlClient library:

   try
   {
        SqlCommand c = new SqlCommand();
        c.CommandType = CommandType.StoredProcedure;
        c.CommandText = "procname";
        c.ExecuteNonQuery()   // execute the stored procedure 
   }
   catch(SqlException sex)
       throw sex;
   catch(Exception ex)
   {
        throw ex;
   }

When ex is caught, its value is blah blah blah + CRLF + 1259

Where is that 1259 coming from? Does it correspond to severity 11?

1

There are 1 best solutions below

5
Tim On

Aha! Just found it. There's a PRINT statement some lines above the RAISERROR. Didn't know that (unrelated) PRINT statements get appended to the error message!

  PRINT 'Fee fie fo fum'

  <snip>

  if @a = @b
     RAISERROR('blah blah blah', 11, 1)
     return

Client-side the SqlException Message property is "blah blah blah" + CRLF + "Fee fie fo fum"