Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I update?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I need to be able to update a table in an asset management database with the following:

IMPORT table --> ASSET table or INCOMPLETE table

I need to be able to go through all the records in the IMPORT table, pick the ones out that have a matching column value (ie 'receive'), see if their serial number exists in the ASSET table, and if it does, update that asset record with the new info. Then, delete the IMPORT record and go to the next record and do the same all the way through the IMPORT table.

Thanks





 
You are thinking procedurally. In the SQL world you need to think of sets of data. Most of the time, you don't need to loop through data sets in SQL. You can JOIN tables and update rows in one table with data in the other with a single query.

Ther exect syntax will depend on your database.

Update Asset Set
col1=import.colA,
col2=import.colB,
col3=import.colC,
col4=import.colD
From Asset
Join Import
On Asset.SerialNumber=Import.SerialNumber
Where Import.COlX='receive' Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top