title: Verification of adding an identical record in SQL
body: <p>I need support, I have a procedure and I need it to return an error when I try to add the same name in the ProductName column:</p>
  <pre><code>USE [Northwind]
          GO
          /****** Object:  StoredProcedure [dbo].[AddNewProduct]    Script Date: 14.09.2021 18:15:53 ******/
          SET ANSI_NULLS ON
          GO
          SET QUOTED_IDENTIFIER ON
          GO
          ALTER procedure [dbo].[AddNewProduct]
          
          @ProductName nvarchar(40), @SupplierID int, @CategoryID int, @QuantityPerUnit nvarchar(20), @UnitPrice money, @UnitsInStock smallint, @UnitsOnOrder smallint, @ReorderLevel smallint, @Discontinued bit
          as
          
          If @ProductName = @ProductName
          
          Begin 
              Declare  @count int, @ProductID int 
          
              
          
              Insert into Products
                  (
                  
                  ProductName ,
                  SupplierID ,
                  CategoryID ,
                  QuantityPerUnit,
                  UnitPrice,
                  UnitsInStock,
                  UnitsOnOrder,
                  ReorderLevel,
                  Discontinued)
                  
                  
                  values
                  (@ProductName, 
                  @SupplierID , 
                  @CategoryID , 
                  @QuantityPerUnit, 
                  @UnitPrice, 
                  @UnitsInStock, 
                  @UnitsOnOrder, 
                  @ReorderLevel, 
                  @Discontinued )
          
          
          End 
          
          else
          Begin
              DECLARE @ErrorMessage NVARCHAR(4000);
              SET @ErrorMessage = 'DDDD';
              RAISERROR (@ErrorMessage, 16, 1);
          end
  </code></pre>
  <p>I want a message to appear when I try to add the same record
  Can you tell me what I am doing wrong or what needs to be added / changed?</p>