1

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?

marc_s
  • 9,052
  • 6
  • 46
  • 52
Icarus
  • 337
  • 2
  • 13

1 Answers1

2

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.

db2
  • 9,708
  • 4
  • 37
  • 58