In this blog post, let’s learn about the error message “132 – The label ‘%.*ls’ has already been declared. Label names must be unique within a query batch or stored procedure.” in Microsoft SQL Server, the reason why it appears and the solution to fix it.
SQL Server Error Message
132 – The label ‘%.*ls’ has already been declared. Label names must be unique within a query batch or stored procedure.
Reason for the Error
This error can occur in SQL Server when you use a label that has already been declared in the same batch or stored procedure. In SQL Server, a label is used to identify a specific point in a stored procedure or batch that can be referenced by a GOTO statement.
Here’s an example of a query that could result in this error:
DECLARE @val INT SET @val = 1 my_label: PRINT @val SET @val = @val + 1 IF @val <= 10 GOTO my_label my_label: -- this line re-declares the label, causing the error

In this example, the label my_label is declared twice, which is not allowed. When you run this query, you will receive the error message:
Msg 132, Level 15, State 1, Line 9
The label ‘my_label’ has already been declared. Label names must be unique within a query batch or stored procedure.
Solution
To fix this error, you need to ensure that all label names are unique within a query batch or stored procedure. In the example above, you can simply remove the second declaration of the my_label label to fix the error.