title: Capture primary key constraint violation in SQL server 2008
body: <p>is there a way to automatically capture (either in SQL server log or Window Event Log) constraint violation due to Inserts into SQL server table with duplicate primary key values?</p>
  
  <p>for Ex: When I try to insert duplicate primary key in SQL Server Management Studio, i get the following error</p>
  
  <p>Msg 2627, Level 14, State 1, Line 2
  Violation of PRIMARY KEY constraint 'PK_<em>Customer</em>_A4AE64D87F60ED59'. Cannot insert duplicate key in object 'dbo.Customer'.
  The statement has been terminated.</p>
  
  <p>But i am unable to find that message in SQL server Logs or Windows Event log.</p>
  
  <p>Thanks</p>