How to import record from only one CSV column within a Sql server column?

Asked

Viewed 268 times

0

I have a csv file with multiple columns "ID,NOME_RUA,DATE" and I want to enter the record of a column "NOME_RUA" which is inside the csv file in my sql server table called "DATA". My "DATA" table in Sql server has multiple columns "ID,NOME_RUA,DESTINATION" however, I only need the "NOME_RUA" record that is in my csv to insert it into a "NOME_RUA" column of the sql server "DATA" table. Does anybody know how to fix this? I just know I’m gonna have to use one Join to specify each record of the TABLE "DATA"

TABLE DATA HAS AS COLUMN:

-ID
-NOME_RUA
-DATA

THE CSV FILE HAS AS A COLUMN:

-ID
-NOME_RUA
-DESTINO
  • 1

    Use Openrowset to open the CSV file as if it were a table. This way you can use JOIN. But it is preferable to import the CSV file into a temporary table, perform the appropriate validations and only after JOIN between the DATA table and the temporary table. Delete the temporary table at the end.

  • @Josédiz thanks man. this tbm can help yes. wanted to go in a more difficult way. This way its simplifies things. Thanks

  • @Josédiz will not want to compose an answer using the OPENROWSET. Just need to include some sample codes in this step-by-step. :)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.