Could alternatively use T-SQL try-catch. However, I'm not sure what kind of negative impact this would have on the server:
SQL:
DECLARE @intVar VARCHAR(MAX), @stringVar VARCHAR(MAX), @default_value INT, @tempVar INT
SET @default_value = NULL
SET @stringVar = 'Hello World!!'
SET @intVar = '550'
PRINT 'Casting @stringVar: '
BEGIN TRY
SET @tempVar = CAST(@stringVar AS INT)
END TRY
BEGIN CATCH
SET @tempVar = @default_value
END CATCH
PRINT @tempVar + 20
PRINT ''
PRINT 'Casting @intVar: '
BEGIN TRY
SET @tempVar = CAST(@intVar AS INT)
END TRY
BEGIN CATCH
SET @tempVar = @default_value
END CATCH
PRINT @tempVar
Output:
Casting @stringVar:
Casting @intVar:
550
Furthermore, I would create user defined functions for those try catch statements that accept a varchar inputString, and int default_value, which returns the integer.