Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
GavinD1977
Yak Posting Veteran
83 Posts |
Posted - 2007-06-06 : 07:24:56
|
Hello all.I have a temp table called #JOB which i know contains data (i can select from it and it shows about 30 rows). The problem is when i am trying to update another table with the contents of the temp table...........query analyser tells me no rows have been updated. here is the code i am using:UPDATE JOB SET JOB.JOB_REF = #JOB.JOB_REF FROM #JOB Does anyone have any ideas where i am going wrong? Cheers in advance. |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-06-06 : 07:27:08
|
| [code]Update jSet Job_Ref = t.Job_refFrom Job j Join #Job t on j.id = t.id[/code]Note: I am assuming ID as Primary Key column here (common joining field).Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2007-06-06 : 07:27:58
|
| Are you trying to insert these records? If you're updating a table, it has to be present in the FROM clause of the statement. This would require you to join JOB to #JOB. However, since you're updating the joining key, this would be problematic!Mark |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-06-06 : 07:28:05
|
[code]UPDATE JSET JOB_REF = T.JOB_REFFROM JOB J INNER JOIN #JOB TON J.somecol = T.somecol[/code] KH |
 |
|
|
pbguy
Constraint Violating Yak Guru
319 Posts |
Posted - 2007-06-06 : 07:28:49
|
| U have to use likeUpdate jSet j.JOB_REF = tj.JOB_REF From JOB j join #job tjon <your condition>--------------------------------------------------S.Ahamed |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-09 : 07:00:45
|
Too many Snipes MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|