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,150 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now