How to Populate a Table based on Entries in Another

E

Ed

I have 2 tables, TBL - Claims & TBL - Transactions. This is a one to many
relationship, 1 Claim has many transactions associated with it. The issue
arises in the fact that I receive the data feed of the transactions, and need
to populate certain fields into the Claims table. The Claims table contains
a unique primary key, Claim Number. This number is a field on the data for
the transaction. What I am thinking I need to do is a find Duplicate query
to return just each unique claim number and then append to claims table.

Any info is greatly appreciated.

Ed
 
B

Bob Barrows

Ed said:
I have 2 tables, TBL - Claims & TBL - Transactions. This is a one to
many relationship, 1 Claim has many transactions associated with it.
The issue arises in the fact that I receive the data feed of the
transactions, and need to populate certain fields into the Claims
table.

Why? The data already exists in the Transactions, doesn't it? Why does
it need to be in two places?
The Claims table contains a unique primary key, Claim Number.
This number is a field on the data for the transaction. What I am
thinking I need to do is a find Duplicate query to return just each
unique claim number and then append to claims table.
There are several questions about updating a field in one table using a
field in another table just this week. For example, there was a message
posted at 3PM yesterday with the subject "Update the values in a table
from another table". Why don't you take a look at it. :)
 
C

Charles Wang [MSFT]

Hi Ed,
You can execute a SQL query in your application to check if the keys being
inserted already exist. For example:
SELECT COUNT(*) FROM CLAIMS WHERE CLAIMNUMBER='XXX'
If this returns a value >0, it means there is already a duplicated key
existed and you do not insert that number; otherwise insert it.

Best regards,
Charles Wang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top