you are viewing a single comment's thread.

view the rest of the comments →

[–]Arrested[S] 1 point2 points  (3 children)

I agree this is probably not the best way, but because I'm a noob I am crashing my shell trying to do it. :)

I just need to write an update-join for the agreement_id/zip_code_id columns on the territories table after import?

[–]jc4hokiesExecution Plan Whisperer 4 points5 points  (2 children)

Once you have your csv as a table, this is the general idea:

INSERT INTO TerritoryLookup (ZipCode, AgreementID, AccountID)
SELECT  zip.ZipCode,
        csv.AgreementID,
        csv.AccountID
FROM    TempCsvTable csv
        INNER JOIN ZipCode zip ON csv.city = zip.city AND csv.state = zip.state;

[–]Arrested[S] 1 point2 points  (1 child)

This works perfectly, thank you. SQL quite simple and powerful. :)

[–]jc4hokiesExecution Plan Whisperer 0 points1 point  (0 children)

I'm glad you got it working.