I'm trying to get a logon trigger to return a custom error. Thus far everything I have tried causes it to return the standard error:
My trigger looks like this:
CREATE TRIGGER Test_Logon_Trigger ON ALL SERVER FOR LOGON AS BEGIN IF ORIGINAL_LOGIN()= 'login_test' BEGIN raiserror('Custom Error',25,16) --PRINT 'Print' --ROLLBACK; END END;
I have tried printing an error message and using a RAISERROR command separately and in combination. I've also tried using the WITH NOWAIT clause on RAISERROR. In all cases it just sends the message to the error log. Does anyone know how to modify the error being returned displayed on the screen? I'm even ok with returning a second error if necessary.