Help!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • papa smurf

    Help!

    Hello folks. I am somewhat new to the SQL World, but have a basic
    understanding of the language. I have a table that I am trying to
    update, and not having much success with it. The table has three keys
    and one foreign key. I cannot find the table the houses the foreign
    key as there is so many to look through. I will leave my error
    message below, along with my SQL syntax for your review. Any
    assistance with this issue is much appreciated!

    (51 row(s) affected)

    (51 row(s) affected)

    (51 row(s) affected)
    Msg 2627, Level 14, State 1, Line 15
    Violation of PRIMARY KEY constraint 'PK_TIAHours'. Cannot insert
    duplicate key in object 'TIATotals'.
    The statement has been terminated.

    (0 row(s) affected)

    Select *
    into ##Temp
    From dbo.TIATotals
    where AssociateNumber = '91060139'
    and DeptIndex = 0

    Update ##Temp set
    DeptIndex = 1 where AssociateNumber = '91060139'
    and DeptIndex = 0

    Delete From TiaTotals
    where AssociateNumber = '91060139'
    and DeptIndex = 0

    Insert Into TiaTotals (AssociateNumbe r,DeptIndex,Rec ordDate,
    ActualMinutes,C orrectedMinutes ,BreakAdjust,
    RcdCreateUser,R cdUpdtUser,RcdC reateDateTime,R cdUpdtDateTime)
    Select AssociateNumber ,DeptIndex,Reco rdDate,
    ActualMinutes,C orrectedMinutes ,BreakAdjust,
    RcdCreateUser,R cdUpdtUser,RcdC reateDateTime,R cdUpdtDateTime From
    ##Temp

    Drop Table ##Temp

    Select *
    From dbo.TIATotals
    where AssociateNumber = '91060139'
    and DeptIndex = 0
  • Dan Guzman

    #2
    Re: Help!

    This question was answered in the microsoft.publi c.sqlserver.ser ver group.
    Please don't post the same question independently to multiple groups as this
    causes duplication of effort on all parties involved.

    --
    Hope this helps.

    Dan Guzman
    SQL Server MVP


    "papa smurf" <DSOldham@gmail .comwrote in message
    news:8ef2bdbd-4868-429d-a9cd-a83eac8d6182@y2 1g2000hsf.googl egroups.com...
    Hello folks. I am somewhat new to the SQL World, but have a basic
    understanding of the language. I have a table that I am trying to
    update, and not having much success with it. The table has three keys
    and one foreign key. I cannot find the table the houses the foreign
    key as there is so many to look through. I will leave my error
    message below, along with my SQL syntax for your review. Any
    assistance with this issue is much appreciated!
    >
    (51 row(s) affected)
    >
    (51 row(s) affected)
    >
    (51 row(s) affected)
    Msg 2627, Level 14, State 1, Line 15
    Violation of PRIMARY KEY constraint 'PK_TIAHours'. Cannot insert
    duplicate key in object 'TIATotals'.
    The statement has been terminated.
    >
    (0 row(s) affected)
    >
    Select *
    into ##Temp
    From dbo.TIATotals
    where AssociateNumber = '91060139'
    and DeptIndex = 0
    >
    Update ##Temp set
    DeptIndex = 1 where AssociateNumber = '91060139'
    and DeptIndex = 0
    >
    Delete From TiaTotals
    where AssociateNumber = '91060139'
    and DeptIndex = 0
    >
    Insert Into TiaTotals (AssociateNumbe r,DeptIndex,Rec ordDate,
    ActualMinutes,C orrectedMinutes ,BreakAdjust,
    RcdCreateUser,R cdUpdtUser,RcdC reateDateTime,R cdUpdtDateTime)
    Select AssociateNumber ,DeptIndex,Reco rdDate,
    ActualMinutes,C orrectedMinutes ,BreakAdjust,
    RcdCreateUser,R cdUpdtUser,RcdC reateDateTime,R cdUpdtDateTime From
    ##Temp
    >
    Drop Table ##Temp
    >
    Select *
    From dbo.TIATotals
    where AssociateNumber = '91060139'
    and DeptIndex = 0

    Comment

    Working...