0

I have table A, where I have 164 distinct values for column CODE as follows:

Code
May-Update-DTO
Terminated
Breaking
One-Two-One
"None"

etc

I also have a CSV file where all of these codes above are mapped to a different values that our software understands:

May-Update-DTO --> None Shift
Terminated --> Value Time
Breaking --> None Dom
One-Two-One --> POE Exec
"None" --> Manual

I have to essentially source this CSV file and update table A per the CSV values above. I can potentially load these CSV files into a local table. What would be the best way to accomplish this? CSV file has like 250 records.

Thank you for any ideas!

3
  • Welcome to the DBA.SE community. Could you possibly supply some example values from the CSV file in your questoin, by clicking the edit link? This would allow community members to possibly answer your question. Currently your questions doesn't contain enough information. Thanks.
    – John K. N.
    Commented Aug 23, 2022 at 7:35
  • Sounds like you should upload the CSV to a table and do a typical JOIN and UPDATE statement. Maybe a screenshot of the CSV in your post would help. Currently unsure if it stores both sides of the mapping in a single column, and what the syntax is.
    – J.D.
    Commented Aug 23, 2022 at 12:13
  • dup on MS Q&A
    – SMor
    Commented Aug 24, 2022 at 13:32

1 Answer 1

1

If you load your CSV into a table, you can do a simple UPDATE with JOIN

UPDATE a
SET Code = csv.NewCode
FROM TableA a
JOIN CsvTable csv ON csv.Code = a.Code;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.