Hey guys,
I'm trying to update some columns in a table using another table's data but there seems to be some problem due to join among the two tables. Here is my query
Currently, the data that i'm working with, there are only 9 records in table Bucket_Staging, which are associated with Bucket = Claims. However, when i run this query it updates 33 records. I ran a SELECT query to check few things and realized that it is updating some records multiple times. So i was wondering if there's a way around this problem because i need to keep track of number of records failed and updated successfully.
Thanking in advance!
I'm trying to update some columns in a table using another table's data but there seems to be some problem due to join among the two tables. Here is my query
Code:
Update DMM_SalesReporting..sapis_test SET Claims_Qty = ISNULL(Claims_Qty, 0) + CONVERT(varchar(30), b.BaseUOMQuantity), Claims_Dollars = ISNULL(Claims_Dollars, 0) + b.BaseUOMAmount, Update_DateTime = getdate(), MM_Batch_Num = convert(varchar(30), b.MM_Batch_Num) FROM DMM_SalesReporting..sapis_test a, Buckets_Staging b WHERE b.bucket = 'Claims' and a.Month_Key = b.Month_key and a.sku_wid = convert(varchar(10), b.FromSku_wid) and a.Plant_wid = convert(varchar(10), b.FromPlant_wid) and a.PlantFlag = b.PlantFlag
Thanking in advance!



Comment