Error Message:
Msg 132, Level 15, State 1, Line 11
The label ‘%.*ls’ has already been declared. Label names must be unique within a query batch or stored procedure.
Severity level:
15.
Description:
This error message appears when you try to specify a label more than once.
Consequences:
The SQL statement cannot be parsed and further execution is stopped.
Resolution:
Error of the Severity level 15 are generated by the user and can be fixed by the SQL Server user. The GOTO labels within a batch or a stored procedure must be unique.
Versions:
All versions of SQL Server.
Example(s):
USE tempdb;
GO
DECLARE @i int;
SET @i = 1;
WHILE @i < 10
BEGIN
SELECT @i
SET @i = @i + 1
IF @i = 4 GOTO Branch_1
END
Branch_1:
SELECT ‘This is Branch_1.’
Branch_1:
SELECT ‘This is Branch_1.’
Remarks:
In the above example we try to declare the label Branch_1 more than once. This raises the error.