Unix Technical Forum

Help!

This is a discussion on Help! within the SQL Server forums, part of the Microsoft SQL Server category; --> Hello folks. I am somewhat new to the SQL World, but have a basic understanding of the language. I ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-16-2008, 02:39 PM
papa smurf
 
Posts: n/a
Default 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 (AssociateNumber,DeptIndex,RecordDate,
ActualMinutes,CorrectedMinutes,BreakAdjust,
RcdCreateUser,RcdUpdtUser,RcdCreateDateTime,RcdUpd tDateTime)
Select AssociateNumber,DeptIndex,RecordDate,
ActualMinutes,CorrectedMinutes,BreakAdjust,
RcdCreateUser,RcdUpdtUser,RcdCreateDateTime,RcdUpd tDateTime From
##Temp

Drop Table ##Temp

Select *
From dbo.TIATotals
where AssociateNumber = '91060139'
and DeptIndex = 0
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-16-2008, 02:39 PM
Dan Guzman
 
Posts: n/a
Default Re: Help!

This question was answered in the microsoft.public.sqlserver.server 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
http://weblogs.sqlteam.com/dang/

"papa smurf" <DSOldham@gmail.com> wrote in message
news:8ef2bdbd-4868-429d-a9cd-a83eac8d6182@y21g2000hsf.googlegroups.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 (AssociateNumber,DeptIndex,RecordDate,
> ActualMinutes,CorrectedMinutes,BreakAdjust,
> RcdCreateUser,RcdUpdtUser,RcdCreateDateTime,RcdUpd tDateTime)
> Select AssociateNumber,DeptIndex,RecordDate,
> ActualMinutes,CorrectedMinutes,BreakAdjust,
> RcdCreateUser,RcdUpdtUser,RcdCreateDateTime,RcdUpd tDateTime From
> ##Temp
>
> Drop Table ##Temp
>
> Select *
> From dbo.TIATotals
> where AssociateNumber = '91060139'
> and DeptIndex = 0


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:29 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com