SA0229 : This syntax of RAISERROR is discontinued. Rewrite the statement using the current RAISERROR(…) syntax or consider using THROW

The topic describes the SA0229 analysis rule.

Message

This syntax of RAISERROR is discontinued. Rewrite the statement using the current RAISERROR(…) syntax or consider using THROW

Description

The rule checks T-SQL code for usages of the deprecated RAISERROR syntax.

RAISERROR in the format RAISERROR integer ‘string’ is deprecated in SQL Server 2012 and discontinued in SQL Server 2014.

How to fix

Rewrite the statement using the current RAISERROR(…) syntax or consider using THROW statement.

Scope

The rule has a Batch scope and is applied only on the SQL script.

Parameters

Rule has no parameters.

Remarks

The rule does not need Analysis Context or SQL Connection.

Effort To Fix
5 minutes per issue.
Categories

Deprecated Features, Bugs

Additional Information
Example Test SQL
SQL
 1declare @errno int
 2declare @errmsg varchar(500)
 3select @errno=@@error
 4
 5if @errno<>0
 6begin
 7    select @errmsg='Error: '+ convert(varchar(10),@errno)
 8
 9    raiserror 200016 @errmsg
10
11    raiserror(@errmsg,200016,1)
12
13    return 1
14end

Analysis Results
  Message Line Column
1 SA0229 : This syntax of RAISERROR is discontinued. Rewrite the statement using the current RAISERROR(…) syntax or consider using THROW. 9 4
See Also

Other Resources