title: Are SQL Server unique constraints "Silent" or do they raise an exception?
body: <p>I want to prevent inserting duplicate values into my tables. At first, I added code to check if the value already existed in the database, but that seems like a lot of overhead / wasted time if I can prevent it at the DDL level.</p>
  <p>So I found <a href="https://stackoverflow.com/questions/1588984/how-to-make-no-duplicates-column-in-sql-server-2008">this</a> and changed one of my tables (as an example) from this:</p>
  <pre><code>CREATE TABLE [dbo].[ACTORS] 
  (
      [Id]      INT IDENTITY (1, 1) NOT NULL,
      [ActorId] CHAR(9)     NOT NULL,
      [Actor]   VARCHAR(50) NOT NULL,
  
      PRIMARY KEY CLUSTERED ([Id] ASC),
  );
  </code></pre>
  <p>to this:</p>
  <pre><code>CREATE TABLE [dbo].[ACTORS] 
  (
      [Id]      INT IDENTITY (1, 1) NOT NULL,
      [ActorId] CHAR(9)     NOT NULL,
      [Actor]   VARCHAR(50) NOT NULL,
  
      PRIMARY KEY CLUSTERED ([Id] ASC),
  
      CONSTRAINT [CK_ACTORS_Column] 
          UNIQUE NONCLUSTERED ([ActorId] ASC)
  );
  </code></pre>
  <p>I want the constraint to prevent a second identical <code>ActorId</code> without whin[g]ing about it. IOW, just bypass it, don't tell me about it, don't stop the app or throw an exception.</p>
  <p>Is this how it works (silently), or will it throw an exception?</p>