Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2007-11-26
3
1,153 Views
Last Modified: 2013-11-24
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
Comment
Question by:jazjef
3 Comments
 
LVL 31

Expert Comment

by:James Murrell
ID: 20353019
0
 
LVL 17

Accepted Solution

by:
pssandhu earned 500 total points
ID: 20353170
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
 
LVL 4

Author Comment

by:jazjef
ID: 20354938
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question