title: SQL Server strange duplicate key error
body: <p>In SQL Server 2008 R2, I have a simple table with the following columns definitions:</p>
  
  <pre><code>Id (PK ,int , not null)
  MeterId (FK , int ,not null)
  InstallDate(DateTime, not null)
  Image(NVarCharMax, null)
  Number (int , not null)
  Comments(NVarChar(300), null)
  </code></pre>
  
  <p>And <code>Id</code> column is set as <code>Identity</code> .</p>
  
  <p>When I run:</p>
  
  <pre><code>insert into Transmitters (MeterId, Number, InstallDate)
    values (952, 777 , '2013-02-21')
  </code></pre>
  
  <p>I get the duplicate key error.</p>
  
  <p>There is no other transmitter with id 777 , </p>
  
  <p>There is a meter with id 952.</p>
  
  <p>This started happening in more than 1 table of my DB.</p>
  
  <p>Any suggestions would be most appriceated.</p>
  
  <p>The entire table script is:</p>
  
  <pre><code>SET ANSI_NULLS ON
  GO
  
  SET QUOTED_IDENTIFIER ON
  GO
  
  CREATE TABLE [dbo].[Transmitters](
      [Id] [int] IDENTITY(1,1) NOT NULL,
      [MeterId] [int] NOT NULL,
      [InstallDate] [datetime] NOT NULL,
      [Image] [nvarchar](max) NULL,
      [Number] [int] NOT NULL,
      [Comments] [nvarchar](300) NULL,
   CONSTRAINT [PK_Transmitters] PRIMARY KEY CLUSTERED 
  (
      [Id] ASC
  )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
  ) ON [PRIMARY]
  
  GO
  
  ALTER TABLE [dbo].[Transmitters]  WITH CHECK ADD  CONSTRAINT [FK_Transmitter_Meter] FOREIGN KEY([MeterId])
  REFERENCES [dbo].[Meter] ([Id])
  GO
  
  ALTER TABLE [dbo].[Transmitters] CHECK CONSTRAINT [FK_Transmitter_Meter]
  GO
  </code></pre>