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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Code..."Insert Into"

Author  Topic 

Dawn
Starting Member

2 Posts

Posted - 2007-01-19 : 14:00:00
Hi,

I have these two tables and I need to get one tiny field copied into the other table. The data in the first table was written over and is now wrong, but the second table has the correct info (it is a backup).

I need the query to match the Studid as the primary key so it only inserts the correct info into the correct students record.

I was writing this and it doesn't work:
INSERT INTO RESULTS --(first table...)
SELECT PRICOMP --(field that has incorrect data)
FROM TEST --(new table..restored from backup)
WHERE TEST.STUDID = RESULTS.STUDID

Okay...I am still new at this and it is probably simple..

Thanks.

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-01-19 : 15:09:52
UPDATE RESULTS
SET PRICOMP = TEST.PRICOMP
FROM RESULTS
INNER JOIN TEST ON RESULTS.STUDID = TEST.STUDID
Go to Top of Page

Dawn
Starting Member

2 Posts

Posted - 2007-01-19 : 15:48:35
Thank you...it worked like a charm....

D
Go to Top of Page
   

- Advertisement -