• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1164
  • Last Modified:

How do I update existing SQL table data from a .csv file using an update query statement containing path of the file?

I am using SQL Express mgmt studio along with DTS for import/export of data....

I have an SQL table called Table1 and I want to update it with data from an Excel file called 'NewData' located at C:\NewData.csv

The file 'NewData' contains a column variable named 'IDNUMBER' and Table1 also contains this variable column called IDNUMBER. I want to update each record/row of data in Table1 with the data from the 'NewData.csv' file where the IDNUMBERS match.

All variable names/headers in NewData.csv also exist in Table1, so the mapping is direct and simple... I just need some help with the statement and integration of the path to the NewData.csv file to get this thing working...any help is really appreciated.
0
jazjef
Asked:
jazjef
1 Solution
 
James MurrellProduct SpecialistCommented:
0
 
pssandhuCommented:
Or, you can just use the import/export wizard to load the data from the csv file into a table in your db and then link Table1 to the table that you just made and do an update.
0
 
jazjefAuthor Commented:
Good ideas guys. I had a hunch that the 'import to a new table and then update' might work.... This appears to be the most feasible method at the moment. The UPDATE option gives me flexibility and its really easy via DTS to get the data into a new temp table.....

I had no knowledge of the 'bulk insert' .... that's an interesting idea. Does 'bulk insert' simply insert the whole file or can I specify that the insert occur where the IDNUMBER matches etc? The link doesn't really say.....
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now