title: Violation of PRIMARY KEY constraint error SQL
body: <p>Here is the code</p>
  
  <pre><code>BEGIN TRANSACTION
  
  INSERT INTO [cresql].[dbo].[AR_Transactions] 
         (DateTime , Dirty, Store_ID, Trans_Type,  Cashier_ID, CustNum, Trans_Amount, Prev_Cust_Balance) 
      SELECT   
         DATEADD(MINUTE, -30, Getdate()), 1, 1001, 'C', 100199,     
         CustNum, -Acct_Balance, Acct_Balance 
      FROM  
         [cresql].[dbo].[Customer] 
      WHERE 
         Acct_Balance &lt;&gt; 0  
  
  UPDATE [cresql].[dbo].[Customer] 
  SET Acct_Balance = -500 
  WHERE Acct_Balance &lt;&gt; 0  
  
  COMMIT TRANSACTION
  </code></pre>
  
  <p>but I am getting this error </p>
  
  <blockquote>
    <p>Msg 2627, Level 14, State 1, Line 3<br>
    Violation of PRIMARY KEY constraint 'pkAR_Transactions'. Cannot
    insert  duplicate key in object 'dbo.AR_Transactions'.<br>
    The statement has been terminated.</p>
  </blockquote>
  
  <p>I am not a pro at SQL...any ideas what I am doing wrong</p>