Primary key check when the field is updated RRS feed

  • Question

  • How do I do to get the primary key check for doublettes when the field (or control ) is updated? I have very long forms and the primary key is the first in order, and a check for doublettes is performed when the form is completed and I try to enter a new record.

    I would like to have the database check the primary key when the primary key field is updated, and the user tabs to the next field, and not when all fields of the form has been completed.

    Wednesday, October 4, 2017 12:17 PM

All replies

  • Hello,

    As per my knowledge, whenever you try to insert or update the primary field column it will throw an error saying :

    Primary key column cannot be updated/deleted.

    If you try to insert the record with the name of existing primary field column then your new record will not get inserted.

    Please Mark as Answer if my post works for you or Vote as Helpful if it helps you. Kapil Singh

    • Proposed as answer by Kapil.Kumawat Wednesday, October 4, 2017 1:23 PM
    Wednesday, October 4, 2017 1:23 PM
  • These are all application issues, the database is happy to do whatever you ask of it.


    Wednesday, October 4, 2017 5:38 PM
  • The issue seems to be more in the realms of your application than Azure SQL Database. Maybe you can architect your survey with several forms. The first form corresponds to the field contained in the primary key column and the second one to the rest of the survey. You than check if the field is already in the database and if not proceed to an insert with dummy values that you replace afterwards with the form values.
    Wednesday, October 4, 2017 6:46 PM
  • Hello,

    On your application you can control which fields on the forms have been updated. On the form you can create an event that runs a SQL Azure stored procedure when the user updates the primary key only.

    Hope this helps.


    Alberto Morillo

    Wednesday, October 4, 2017 11:17 PM