title: SQL Server : trigger to retrieve duplicates and stop them from being entered whilst inserting new values
body: <p>I'm trying to look for duplicates in a table column. The column <code>name</code> is alphanumeric and table is a user-defined table</p>
  
  <p>This is my trigger:</p>
  
  <pre><code>ALTER TRIGGER [dbo].[DUPLICATES]
  ON [dbo].[AMGR_User_Fields_Tbl]
  FOR INSERT, UPDATE
  AS
     DECLARE @Alphanumericcol VARCHAR (750)
  
     -- This trigger has been created to check that duplicate rows are not inserted into table.
     -- Check if row exists
     SELECT @Alphanumericcol
     FROM Inserted i, AMGR_User_Fields_Tbl t
     WHERE t.AlphaNumericCol = i.AlphaNumericCol
       AND t.Client_Id = i.Client_Id
  
     --  (@Alphanumericcol = 1)
     -- Display Error and then Rollback transaction
     BEGIN
         RAISERROR ('This row already exists in the table', 16, 1)
         ROLLBACK TRANSACTION
     END
  </code></pre>
  
  <p>The result I get is, if I input a duplicate number it fills in a null in the column so my question is how do I get it to tell me its duplicate and let me insert a new one</p>