November 17, 2006 at 11:09 am
This seems like a basic thing to me, but I can't get it to work!
I have a tblProject, which has a status of "A" and "I". In order for some calculations to be done, the status for all needed to be set to "A". I made a temporary table of all those with an original status of "I", and then changed the status in tblProject to "A" for every record. Now the calcuations are complete, I need to make all those that were originally "I" back to "I" again, using my temporary table. Here is the code I am trying to use:
update tblProject, tblTemp_Project
set tblProject.status = 'I'
where tblProject.project = tblTemp_Project.project
This fails on the first line "...Incorrect syntax near "tblTemp_Project"...." and I am not really sure why. I tried just referencing the table I wanted to update, but still got errors...any ideas?
I have also tried doing the update like this:
update pjproj p
set p.status_pa =
(select t.status_pa from temp_active_proj t
where t.project = p.project)
which also doesn't work. Any suggestions??
Thanks!
November 17, 2006 at 11:18 am
You could try this with or without the WHERE clause - I don't know how big your table is and whether this will help..
UPDATE tblProject SET
tblProject.status = 'I'
FROM
INNER JOIN tblTemp_Project ON( tblProject.project = tblTemp_Project.project)
WHERE tblTemp_Project.status = 'I'
I wasn't born stupid - I had to study.
November 17, 2006 at 11:24 am
Hmmm, I tried that, but still get an "incorrect syntax" error...I think there must be something really obvious that I am just missing
The main table has just over 1000 records and the temp table about 600...
November 17, 2006 at 11:39 am
UPDATE tblProject SET
tblProject.status = 'I'
FROM dbo.tblProject
INNER JOIN tblTemp_Project ON( tblProject.project = tblTemp_Project.project)
WHERE tblTemp_Project.status = 'I'
November 17, 2006 at 12:06 pm
AAhhhhh......thank you so much!
November 17, 2006 at 12:13 pm
NP. That's why I find it usefull to use the check syntax button before posting a solution .
November 17, 2006 at 12:20 pm
Normally I use the parse button before trying to submit anything, and it didn't see a problem with that! Oh well, thanks again!
November 17, 2006 at 12:22 pm
My comment was a little more intended for Farrell , !
November 18, 2006 at 12:36 pm
I did not even see that I forgot a table after the FROM. Well, someone needed to open themselves up for a little fun at their expense - guess that would be me...
I wasn't born stupid - I had to study.
November 18, 2006 at 5:44 pm
If that can make you feel better, then Thanx .
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply