my datasource in excel that i want to import to table A in SQL Server
ID | NAME |
---|---|
ID3 | Three |
ID4 | Four |
tableA collumn in SQL
ID | NAME | FLAG |
---|---|---|
ID1 | One | BCM |
ID2 | Two | KKLK |
tableB collumn in SQL
NAME | FLAG |
---|---|
One | BCM |
Two | KKLK |
Three | KUR |
Four | BWU |
how i can import my datasource in excel to my tableA in SQL and collumn Flag in tableA automatically filled based on the flags in table B according to the names in tableB?
I’ve made a manual query, but I want every time I import data to tableA, the flag column will be automatically filled in without having to re-execute the query manually
Query:
UPDATE TABLEA SET FLAG = TABLEB.FLAG
FROM TABLEA
INNER JOIN TABLEB ON TABLEB.NAME = TABLEA.NAME
The results I expect when I import data from Excel are like this
ID | NAME | FLAG |
---|---|---|
ID1 | One | BCM |
ID2 | Two | KKLK |
ID3 | Three | KUR |
ID4 | Four | BWU |
Rafles Eben Ezer Hutapea is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.