-- Collection of code snippets by Arne Vajhøj 
-- posted to eksperten.dk, usenet and other places (2002-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
