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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying column from one table to another, linked table 1

Status
Not open for further replies.

sigep722

MIS
Apr 29, 2002
8
US
I have a situation with two linked tables. I need to move a column from table A to column B (of course, only for certain records).

Here is one of my first attempts.
Code:
Update UserDefinedFields
Set UDFVCSD2 = (Select Buyer From OeorderHeader),
    UDFVCSD3 = (Select CustomerPoNo From OeorderHeader)
Where TableName = "OeorderHeader" AND RowId In (Select RowPointer From OeorderHeader);
[\code]
The error says the subqueries return more than one value, which makes sense; however, I don't know how to make them return the apporpriate value.

Can one copy a column from one table to another with an update query? If not, do I need to use a cursor?
 
What is the relationship between UserDefinedFields and OeorderHeader. Assuming that key coumn(s) exist you'l use a query like the following.

Update UserDefinedFields
Set UDFVCSD2 = h.Buyer,
UDFVCSD3 = h.CustomerPoNoWhere

From UserDefinedFields f
Join OeorderHeader h
On f.keycol=h.keycol

If there is no column relationship, how can you determine which row on UserDefinedFields to update with data on a row in OeorderHeader? Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Thanks a lot. I think we got it. The UserDefinedField table is linked to the Oeorderheader table with the UDF.RowId = OeH.Rowpointer. Additionally, the UDF.TableName = "OeorderHeader". The TableName and RowId serve as the UDF table's primary keys.

The format you provided helped us solve the problem. I really appreciate the help.

David Segraves
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top