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
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