-- Collection of code snippets by Arne Vajhøj 
-- (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
DROP PROCEDURE usp_test
GO
CREATE PROCEDURE usp_test
AS 
DECLARE @sql NVARCHAR(1000)
DECLARE @retval INTEGER
SET @sql='IF EXISTS (SELECT * FROM t1)
BEGIN 
    RAISERROR(''not so'',16,1)
END'
PRINT 'a'
EXEC sp_executesql @sql
IF @@ERROR = 0
BEGIN
    PRINT 'b'
END
GO
