sql server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ha Nguyen
    New Member
    • Aug 2009
    • 21

    sql server

    Hi all,
    I have a problem that need to solve: I have a table that is called empVisit.
    There was a error when inserting: Violation of PRIMARY KEY constraint 'PK_EmpVisit'. Cannot insert duplicate key in object 'dbo.EmpVisit'.
    The statement has been terminated.
    PRIMARY KEY is Id field of the table. I need to insert a new record with the same Id value to that table.
    So how to solve this problem?
    Pls help me, thanks in advance,

    --Ha
  • myusernotyours
    New Member
    • Nov 2007
    • 188

    #2
    You should start thinking about why you really want to insert the same ID twice. you most probably have a badly designed database and/or program.

    Regards,

    Alex.

    Comment

    • Ha Nguyen
      New Member
      • Aug 2009
      • 21

      #3
      Originally posted by myusernotyours
      You should start thinking about why you really want to insert the same ID twice. you most probably have a badly designed database and/or program.

      Regards,

      Alex.
      So, there is no way to solve this problem, right?

      Comment

      • myusernotyours
        New Member
        • Nov 2007
        • 188

        #4
        Originally posted by Ha Nguyen
        So, there is no way to solve this problem, right?
        Absolutely. There is no way you can possibly solve this huge monster of a problem. Not in 100 years.

        Regards,

        Alex.

        Comment

        • Ha Nguyen
          New Member
          • Aug 2009
          • 21

          #5
          Anyway, thanks for your answer, Alex

          Ha

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by Ha Nguyen
            .. I need to insert a new record with the same Id value to that table.
            ..
            Why do you need to insert a duplicate key?
            Do you just want to update the other values instead?
            If you do need to have many records with the same value in the key field then your key constraint is not correct and should be removed.

            Comment

            Working...