Sql-server – Raise error from Stored PROC in SQL Server PDW

sql-server-2008-r2sql-server-pdwstored-procedures

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?

Best Answer

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.