Tuesday, July 28, 2015

Generate a custom error message in Execute SQL Task in SSIS

Generates an error message and initiates error processing for the session. RAISERROR can either reference a user-defined message stored in the sys.messages catalog view or build a message dynamically. The message is returned as a server error message to the calling application or to an associated CATCH block of a TRY…CATCH construct.

declare @position varchar(20)
set @position = ?

if (@position like 'eng%' or @position like 'man%')
begin
delete from dbo.employee where position = @position;

end
else 
begin
raiserror ('position is an unidentified type',10,1)
end
go

Cheers!
Uma

1 comment: