I need to do some validation inside a stored procedure before I continue processing but SQL Server PDW (SQL Server 2008 R2) does not support RAISEERROR inside stored procedures.

Is there any other way that I can raise an error with a specific error message inside a stored procedure?

I can try and do something illegal, like force a "division by zero" error, but the error would be misleading.

I'd like to be able to raise an error specifying the exact problem that's occurring.

Any other way?


I don't know if this will work with PDW specifically, but I've got an awful, dirty hack I use with user-defined functions, which also don't allow RAISERROR. Just attempt to cast a varchar literal containing your error message to int.

SELECT CAST('Carburetor failure detected.' AS int)

It's not the prettiest error output, but it's better than nothing.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.