Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. primary key

primary key

Scheduled Pinned Locked Moved Database
question
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Neha_Gupta
    wrote on last edited by
    #1

    If a primary key is dropped from a table and some records are duplicated after dropping primary key, then is it possible to apply the primary key on the same column. If yes, then how??

    NEHA GUPTA

    R D 2 Replies Last reply
    0
    • N Neha_Gupta

      If a primary key is dropped from a table and some records are duplicated after dropping primary key, then is it possible to apply the primary key on the same column. If yes, then how??

      NEHA GUPTA

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      No, not really. The whole point of a primary key is that it is unique for each row (be it a surrogate key or a key made up from several columns). If you have duplicate rows then, by definition, you will be breaking the rule. Remove the duplicate rows and then apply a primary key. Why would you deliberately remove the primary key and add duplicate rows?

      "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

      1 Reply Last reply
      0
      • N Neha_Gupta

        If a primary key is dropped from a table and some records are duplicated after dropping primary key, then is it possible to apply the primary key on the same column. If yes, then how??

        NEHA GUPTA

        D Offline
        D Offline
        Dhyanga
        wrote on last edited by
        #3

        ya how can again you set the primary key which already have two rows of same key ??? it is not possible...

        suchita

        N 1 Reply Last reply
        0
        • D Dhyanga

          ya how can again you set the primary key which already have two rows of same key ??? it is not possible...

          suchita

          N Offline
          N Offline
          Neha_Gupta
          wrote on last edited by
          #4

          but there is some option when we alter the table, (when we add constraint) with an option "with check" and "with nocheck". What is that option? Please clarify..

          NEHA GUPTA

          L 1 Reply Last reply
          0
          • N Neha_Gupta

            but there is some option when we alter the table, (when we add constraint) with an option "with check" and "with nocheck". What is that option? Please clarify..

            NEHA GUPTA

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            If you add a new constraint, Sql Server will test whether or not all of the records that are currently in the table pass that constraint. Adding the NOCHECK option will skip that test. You'd have to remove any double entries to recreate your primary key.

            I are Troll :suss:

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups