November 20, 2006 at 2:17 pm
You want to update instead of inserting, you you need to update data between 2 different tables?
November 20, 2006 at 2:23 pm
What do you mean i dont understand i guess what are you saying.Can you be a little more clear please.
THANKS
November 20, 2006 at 2:29 pm
Please post sample data from all tables and the required output you need us to create. SQL and data are universal language
.
November 20, 2006 at 2:59 pm
Values in the table TransactionCounts_Sort-sampledata
ID CalcAction SortOrder
1 Total Record Count 1
2 Record Count of Unique Policies 2
3 Record Count by Status 3
Value in TransactionCounts-sample data
ID Month_of_file CalcAction TableValue CalculatedValue
1 12/1/2004 Total Record Count 66476
2 12/1/2004 Record Count of Unique Policies 30356
3 12/1/2004 Record Count by Status A 66293
4 12/1/2004 Record Count by Status D 183
November 20, 2006 at 3:00 pm
what i want to do is replace the values of CalcAction Column in TransactionCounts table with the values of CalcAction Column
in the second table which is TransactionCounts_Sort
November 20, 2006 at 3:15 pm
From the examples you give, and the question...I don't see what you are trying to do. You say you want to remove the values in the CalcAction column in the bottom table with the exact same values from the top table. That doesn't sound right.
So, based on the two tables you showed us, what do you want the final result to look like?
-SQLBill
November 20, 2006 at 4:57 pm
Value in TransactionCounts- what iam looking for
ID Month_of_file CalcAction TableValue CalculatedValue
1 12/1/2004 1 66476
2 12/1/2004 2 30356
3 12/1/2004 3 A 66293
November 20, 2006 at 5:30 pm
Is the 'new' CalcAction based on the TransactionCounts_Sort.SortOrder or the TransactionCounts_Sort.ID?
What do you want to have happen with the second Record Count by Status row?
Something like:
UPDATE TransactionCounts
SET TransactionCounts.CalcAction = TransactionCounts_Sort.CalcAction
FROM TransactionCounts, TransactionCounts_Sort
WHERE TransactionCounts.ID = TransactionCounts_Sort.ID
-SQLBill
November 20, 2006 at 5:36 pm
it will show 3 in CalcAction column of transactioncount table.Dont you think i have to establish some sort of relationship between two tables such as primary key and foreign key
November 21, 2006 at 9:05 am
No. Not for a basic update like that. Primary/Foreign keys are for when you are inserting data and you need to maintain integrity of the data. You just said you want to update some data in one table.
-SQLBill
Viewing 10 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply