<turbo-stream action="update" target="wiki_card"><template>

<h1>Violation of PRIMARY KEY constraint</h1>
<div class="trix-content"><p><strong>Scenario</strong>: Occurs when trying to insert a record with a duplicate value in a column that has a PRIMARY KEY constraint.<br><br><strong>Error Message</strong>: <code>Native Error Code: 2627 SQL State: 23000 [Microsoft][ODBC SQL Server Driver][SQL Server]Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object 'dbo.XYZ'. The duplicate key value is (XZZ).</code><br><br><strong>Cause</strong>: The record already exists in the database, or the key field is not unique in the source data.<br><br></p><div><strong>Resolution</strong>:<br><br></div><ul><li>Check if the record already exists by using a query (<code>SELECT * FROM [Table] WHERE [PrimaryKeyColumn] = 'Value'</code>).</li><li>Ensure the source data generates unique keys (e.g., combining fields or using GUIDs).</li></ul></div>
</template></turbo-stream>

